2013-10-18 24 views
0

可以通過Ember.Select觸發selectionBinding的動作而不是綁定值?我正在尋找加載JSON取決於選擇框的值,但selectionBinding只綁定一個值,而不是運行一個函數。例如,如何在Ember.Select中調用函數而不是綁定值

App.SettingsController = Em.Controller.extend({ 
    loadStartDates: function() { 
       // Load dates from server 
     } 
    }); 

而且我Ember.Select標籤

{{view Ember.Select 
    class="form-control" 
    selectionBinding='loadStartDates' 
    name="program_academic_year" 
    id="program_academic_year" 
    contentBinding="programAcademicYears"}} 

我可以調用一個函數在我的控制器,而不是選擇的變化設定的值?

回答

2

Ember.SelectselectionBinding必須綁定到一個值,但如果你想在選擇被改變時觸發一個功能,所有你需要做的就是觀察該值。

App.SettingsController = Em.Controller.extend({ 
    loadStartDates: function() { 
    // Load dates from server 
    }.observes('selection') 
}); 

{{view Ember.Select selectionBinding="selection"}} 
相關問題