[英]Ember.js How to observe selection changes with view Ember.Select multiple=true?
我試圖觀察簡單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有這個問題: http : //jsbin.com/
版本 :車把1.0.0,ember 1.0.0
將TOPICS
變量更改為topics
將解決此問題。 我認為這是因為這個問題https://github.com/emberjs/ember.js/issues/3098 。
在您的topicsSelected
觀察者中,如果您想觀察選擇,則需要observes('topics.length')
。
看看你更新的jsbin http://jsbin.com/ofONeQ/14/edit
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.