The event fires well on a wildcard selector, but fails if I use a specific ID for the selector.
This works:
$("*").click ->
console.log "entered event."
$("#tellafriend").dialog
modal: true
buttons:
Ok: ->
$(this).dialog "close"
Yet, this doesn't:
$("#tell-a-friend").click ->
console.log "entered event."
$("#tellafriend").dialog
modal: true
buttons:
Ok: ->
$(this).dialog "close"
And my relevant HTML:
<ul class="actions">
<li><a href="#">Home</a></li>
<li>|</li>
<li><a href="#" id="tell-a-friend">Tell a Friend</a></li>
</ul>
Am I missing something in CoffeeScript for this to work? Maybe jQuery selectors are formatted differently in CoffeeScript?
This is the rendered Javascript that my application serves (Rails convert CoffeeScript to JS when serving the pages):
(function() {
$("#tell-a-friend").click(function() {
console.log("works");
return $("#tellafriend").dialog({
modal: true,
buttons: {
Ok: function() {
return $(this).dialog("close");
}
}
});
});
}).call(this);
$(document).ready()bit. Testing. Edit: Yes, that was the problem. Massive brainfart on my part. This always happens when I'm in new territory (coffeescript) I forget the basics.