CoffeeScript sempre retorna em função anônima
Estou tentando escrever alguma função CoffeScript que marque todas as caixas de seleção em uma tabela ao marcar a caixa de seleção t
Minha função no CoffeeScript é assim:
$("table.tableview th input:checkbox").live 'click', ->
checkedStatus = this.checked
$("table.tableview tbody tr td:first-child input:checkbox").each ->
this.checked = checkedStatus
Funciona muito bem para marcar todas as caixas. No entanto, ao desmarcar, não funciona. O JS compilado fica assim:
$("table.tableview th input:checkbox").live('click', function() {
var checkedStatus;
checkedStatus = this.checked;
return $("table.tableview tbody tr td:first-child input:checkbox").each(function() {
return this.checked = checkedStatus;
});
});
Não funciona porque depois que o primeiro é definido como falso, o retorno da função será falso. No entanto, não tenho idéia de como suprimir esse comportamento de retorno padrão do script de café. Por favor ajude
Quando adiciono um "true" conforme a sugestão de Flambino, recebo o seguinte JS
$("table.tableview th input:checkbox").live('click', function() {
var checkedStatus;
checkedStatus = this.checked;
$("table.tableview tbody tr td:first-child input:checkbox").each(function() {
return this.checked = checkedStatus;
});
return true;
});
A única maneira de obter a declaração de retorno dentro da função é colocando-a assi
$("table.tableview tbody tr td:first-child input:checkbox").each ->
this.checked = checkedStatus
true
O que estou fazendo de errado ? Obrigado pela ajuda até agora