eguneys
eguneys

Reputation: 6396

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

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?

Upvotes: 1

Views: 89

Answers (1)

blessanm86
blessanm86

Reputation: 31779

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.

Upvotes: 1

Related Questions