2015-02-11 26 views
0

Hello Stack Overflowers!Ember複選框輸入助手不能用戶'on'屬性

鑑於:

{{#each user in model itemController="user"}} 
    <tr> 
    .... 
    <td>{{ input type="checkbox" action="acceptChanges" on="click" class="toggle" checked=user.is_disabled }}</td> 

然後渲染引發錯誤視圖時:

Uncaught TypeError: string is not a function 

然而,去除在 '接通' 屬性,使得加價是:

<td>{{ input type="checkbox" action="acceptChanges" class="toggle" checked=user.is_disabled }}</td> 

然後頁面呈現。我的目標是將「acceptChanges」控制器方法綁定到更改此值。 「acceptChanges」是一個ObjectController方法,它只是將對象保存在商店中。

這裏是objectcontroller方法我試圖撥打:

AdminApp.UserController = Ember.ObjectController.extend({ 

    actions: { 
     editUser: function(){ 
      this.set('isEditing', true); 
     }, 
     acceptChanges: function(){ 
      console.log("accepting changes"); 
      this.set('isEditing', false); 
      var model = this.get('model'); 
      model.save(); 
     } 
    }, 

回答

0

{{action="acceptChanges" on="click"}}將無法​​正常工作。嘗試{{change="acceptChanges"}}。 請參閱此link以更詳細地解釋Ember的文檔。複選框接受更改事件,它可能更適合您的情況。 如果這不起作用,請嘗試在此帖子上接受的答案:Trigger an action on the change event with Ember.js checkbox input helper?

+0

感謝反引用,安迪 – 2015-02-11 18:41:20

+0

它呈現,它只是不調用該方法。 – RedMage 2015-02-11 18:42:10

+0

我的不好,應該改變,不要點擊。編輯以顯示正確的事件。 – 2015-02-11 18:46:46