0

How would one write this with the correct coffeescript syntax?

$("select#test").bind({
  "focus": function(ev, obj) {
    # Do something when the focus event is triggered
  }
});

My attempt is not correct:

$("select#test").bind 
  "focus": (ev, obj) -> 
    # Do something when focus event is triggered

2 Answers 2

1
$('select#test').bind 'focus': (ev, obj) ->
  # Do something when the focus event is triggered
  return
Sign up to request clarification or add additional context in comments.

Comments

1

Your code is totally fine. Except for the fact that // isn't how you do comments, and that's what's crashing it, haha. # is for comments

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.