2014-05-09 103 views
2

我正試圖將列表程序掛鉤到單選按鈕更改。但由於某些原因,我不能得到這個工作:主幹單選按鈕更改事件

我得到了什麼是thsi:

HTML:

<input type="radio" name="hat" value="1"> 
<input type="radio" name="hat" value="2"> 
<input type="radio" name="hat" value="3"> 

我嘗試在我看來是這樣的渲染方法來設置製表了:

this.listenTo(this, 'change input[type=radio]', this.changedRadio); 

但是調整單選按鈕不會導致調用「changedRadio」beeing。

相反,我得到這個在控制檯:

Unable to get property 'controlMap' of undefined or null reference 

回答

8

在你的代碼正在收聽的視圖中的change事件和骨幹視圖不會觸發該事件。

嘗試將其添加到視圖這樣的活動:

events: { 
    'change input[type=radio]': 'changedRadio' 
}, 

changedRadio: function() { 
    ... 
}, 

render: function() { 
... 
相關問題