2

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(@).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.

2 Answers 2

4

You're simply missing the = sign before the function literal:

makeTall = ->
    jQuery(@).find('ul:first').slideDown
        queue:false
        duration:220
Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.