سؤال

I've tried to observe selection change for simple Ember.Select and it works, but when I use select with multiple=true it fails. Here some code:

 {{view Ember.Select
 multiple=true
 contentBinding="App.TopicController"
 selectionBinding="content.TOPICS"
 optionLabelPath="content.label"
 optionValuePath="content.id"}}

When I change selection on my input it must trigger observer:

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 with this problem: http://jsbin.com/

Versions: handlebars 1.0.0, ember 1.0.0

هل كانت مفيدة؟

المحلول

Changing the TOPICS variable to topics will solve this problem. I think this happen because this problem https://github.com/emberjs/ember.js/issues/3098.

In your topicsSelected observer if you want to observe the selection just observes('topics.length') is needed.

Give a look in your updated jsbin http://jsbin.com/ofONeQ/14/edit

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top