0

可以Ember.Select触发一个动作selectionBinding而不是绑定一个值吗?我希望根据选择框的值加载 JSON,但selectionBinding只是绑定一个值,而不是运行一个函数。例如,

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"}}

我可以在我的控制器中调用一个函数而不是在选择更改时设置一个值吗?

4

1 回答 1

2

Ember.Select'sselectionBinding必须绑定到一个值,但是如果您想在选择更改时触发函数,您需要做的就是观察该值。

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

{{view Ember.Select selectionBinding="selection"}}
于 2013-10-18T03:40:32.263 回答