Javascript js如何使用view Ember观察选择的更改。选择multiple=true?

Javascript js如何使用view Ember观察选择的更改。选择multiple=true?,javascript,ember.js,observers,Javascript,Ember.js,Observers,我试着观察simple Ember.Select的选择更改,它可以工作,但当我使用Select with multiple=true时,它失败了。下面是一些代码: {{view Ember.Select multiple=true contentBinding="App.TopicController" selectionBinding="content.TOPICS" optionLabelPath="content.label" optionValuePath="content.

我试着观察simple Ember.Select的选择更改,它可以工作,但当我使用Select with multiple=true时,它失败了。下面是一些代码:

 {{view Ember.Select
 multiple=true
 contentBinding="App.TopicController"
 selectionBinding="content.TOPICS"
 optionLabelPath="content.label"
 optionValuePath="content.id"}}
当我更改输入上的选择时,它必须触发观察者:

App.Configuration = Em.Object.extend({
    TOPICS:[],

  // this observer must work when selection changes
  topicsSelected: function() {
    console.log('topics selection changed!');
  }.observes('TOPICS', 'TOPICS.@each', 'TOPICS.length')

});
JSBin解决了这个问题:


版本:将
主题
变量更改为
主题
将解决此问题。我认为这是因为这个问题

在您的
主题中选择了
观察者,如果您想观察选择,只需
观察('topics.length')

查看更新后的jsbin
观察('topics.length')
是不够的。如果选择了一个项目,而用户选择了另一个项目,则长度不会改变。只需观察('topics@each')
就可以了。