0
我有一個表單,當前包含一個表單組和下面的代碼。流星,將事件添加到單選按鈕會禁用它們
<div class="form-group">
<label>Role</label>
<div class="radio">
<label>
<input type="radio" name="role-options" id="role-foreman" value="Foreman" checked="">Foreman
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="role-options" id="role-super" value="Superintendent">Superintendent
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="role-options" id="role-admin" value="Superintendent">Admin
</label>
</div>
</div>
這一切都如預期,但只要我的事件處理程序添加到三個輸入,我失去了表單組,這是當按下一個單選按鈕,它成爲唯一入選的默認功能工程一。
目前我在模板的事件處理程序中有以下代碼。
"click #role-foreman": (e) ->
console.log e
showAddProjects = true
"click #role-super": (e) ->
console.log e
showAddProjects = false
"click #role-admin": (e) ->
console.log e
showAddProjects = false
我所尋找的是按鈕的默認行爲仍然存在,但隨後又運行時按下按鈕的其他代碼。
而且最好是'返回FALSE'或'返回undefined'。此外,我建議在函數的第一行上運行'e.preventDefault()'。 –