开发者

Javascript to Coffeescript conversion

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜