How to determine item being added/removed to an observed array in ember?

懵懂的女人 提交于 2020-02-02 16:04:27

问题


It explains here how to observe items in an array with ember. My question is how can I determine the item being added/removed with this method?


回答1:


You can use the addArrayObserver method to find items added/removed from an array.

The code will look something like this

that.get('content').addArrayObserver(this, {
  willChange: Ember.K,
  didChange: function(array, start, removeCount, addCount) {
    alert(array[start]);
  }
});

More information can be found here.

Here is a link to a working demo.



来源:https://stackoverflow.com/questions/30011028/how-to-determine-item-being-added-removed-to-an-observed-array-in-ember

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!