I\'m trying to write some CoffeScript function which checks all checkboxes in a table upon checking the checkbox in the th.
My function in CoffeeScript looks like th
If you just use return
(or, equivalently, undefined
) as the last line of a function, the CoffeeScript compiler will give you JS with no return
at all. So the most efficient way of writing your code would be
$("table.tableview th input:checkbox").live 'click', ->
checkedStatus = this.checked
$("table.tableview tbody tr td:first-child input:checkbox").each ->
this.checked = checkedStatus
return
return
(You can safely do without the second return
, of course. Only a return value of false
has an effect in jQuery.)
There was also a proposed syntax (-/>
) for defining a function with no return value; see issue 899.