onArrayChanged: function(obj, keyName, value) {
// What is value here, exactly?
}.property('array.@each')
当一个元素被添加到数组中时,我如何知道添加了哪个值?同样,当从数组中删除一个值时,我如何访问它?
onArrayChanged: function(obj, keyName, value) {
// What is value here, exactly?
}.property('array.@each')
当一个元素被添加到数组中时,我如何知道添加了哪个值?同样,当从数组中删除一个值时,我如何访问它?
看看addArrayObserver,见http://jsfiddle.net/pangratz666/EE65Z/:
var a = Ember.A('a b c d e f g'.w());
var o = Ember.Object.create({
arrayWillChange: Ember.K,
arrayDidChange: function(array, start, removeCount, addCount) {
console.log(arguments);
}
});
a.addArrayObserver(o);