Being not the best with javascript I am converting my file to coffeescript.
Here is my original JS
function makeTall(){
jQuery(this).find('ul:first').slideDown(
{queue:false, duration:220}
);
}
I have tried the following.
makeTall ->
jQuery(@开发者_如何学C).find('ul:first').slideDown
queue:false
duration:220
Which produces.
makeTall(function() {
return jQuery(this).find('ul:first').slideDown({
queue: false,
duration: 220
});
});
The new style just confuses me a little and wanted to ask is this correct ?
I also tried.
You're simply missing the =
sign before the function literal:
makeTall = ->
jQuery(@).find('ul:first').slideDown
queue:false
duration:220
You might find this project to be helpful
https://github.com/rstacruz/js2coffee/
For your above case it produces:
makeTall = ->
jQuery(this).find('ul:first').slideDown
queue: false
duration: 220
精彩评论