1

I am new to coffeescript. However I didn't find any suitable word to put the question.

I have a coffeescript like this :

@collection.each (student) =>               
            ($(@el).find("#table .table").append new Item({model:student}).el)
                .find("td:last-child").hide()   

However, is there any better way to do this method chaining than this ugly syntax ? I want to find the td:last-child from $(@el) only, without any brackets. How can I do that?

1 Answer 1

1

Why not put the parentheses on the append to match the other function calls?

@collection.each (student) =>     
    $(@el).find("#table .table")
        .append(new Item(model: student).el)
        .find("td:last-child")
        .hide()
Sign up to request clarification or add additional context in comments.

2 Comments

so in a manner I still have to put the brackets to differentiate between the Item and the find chaining right ?
@Joy: You're going to need parentheses somewhere if you want to chain.

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.