I convert my old JS files into CoffeeScript, In my public controller I
used this functions
$(’#events a’).lightBox()
$(document).ready ->
$("#slider").easySlider
auto: true,
continuous: true
they load inside application.js like this
(function() {
$(’#events a’).lightBox();
$(document).ready(function() {
$("#slider").easySlider({
auto: true,
continuous: true
});
});
but it doesnt seems to work, also tried with an alert “hello” and doesnt
work neither, what i’m doing wrong?
Try
$ ->
$(’#events a’).lightBox()
$("#slider").easySlider
auto: true
continuous: true
There is an online js to coffeescript converter out there, I just can’t
find
the link right now too.
On 23 Jul 2011, at 08:01, Martin W. wrote:
Try
$ →
$(‘#events a’).lightBox()
$(“#slider”).easySlider
auto: true
continuous: true
There is an online js to coffeescript converter out there, I just
can’t find the link right now too.
http://ricostacruz.com/js2coffee/
Hope this helps
Best regards
Peter De Berdt
Peter De Berdt wrote in post #1012552:
On 23 Jul 2011, at 08:01, Martin W. wrote:
Try
$ →
$(‘#events a’).lightBox()
$(“#slider”).easySlider
auto: true
continuous: true
There is an online js to coffeescript converter out there, I just
can’t find the link right now too.
http://ricostacruz.com/js2coffee/
Hope this helps
Best regards
Peter De Berdt
that’s not the problem, the functions are well done. otherwise an alert
“hello” should work and i will get an error somewhere in the file.
and yes, .call(this); is placed inside the file
I found the problem, a jquery plugin isnt loading well.
Uncaught TypeError: undefined is not a function
but it was working after rails 3.1, is beeing loaded at the end of the
file so it should be ok
(bubblepopup plugin)
the problem is that coffee creates this in a private scope, so any
method from inside that scope can’t be called…
try
window.testFunction: (param) →
alert param
and
testFunction2: (param) →
alert param
and check ‘compiled’ code of both
the function with “window” prefix will be available globally, instead of
the other one
there’s a big difference between (after ‘compiling’)
(function () {
var testFunction2 = function(param) {
alert(param);
}
}();
and
var testFunction = function(param)
alert(param);
}
as for the first case, there’s no publicly exposed part of the first
testFunction2 function.
tom
On Jul 23, 2011, at 17:47 , Tomas R. wrote:
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
–
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache