如何确定要添加/删除的观察数组中的项目? [英] How to determine item being added/removed to an observed array in ember?

查看:71
本文介绍了如何确定要添加/删除的观察数组中的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它解释了此处如何观察具有余烬的阵列中的项目。我的问题是如何确定使用此方法添加/删除的项目?

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?

推荐答案

您可以使用 addArrayObserver 方法来查找从数组中添加/删除的项目。

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

代码看起来像这样

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

更多信息可以在这里找到。

More information can be found here.

这是一个工作演示的链接。

这篇关于如何确定要添加/删除的观察数组中的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆