Sean X. Yu
Sean X. Yu

Reputation: 123

emberjs get('lastObject') bug?

I'm looping through an array using Ember.Array#lastObject property:

while (last = this.get('clickViews.lastObject')) {
  // perform some actions to last
  this.get('clickViews').removeObject(last);
}

When all objects from the clickViews array have been removed, this.get('clickViews.lastObject') still returns an object. Is there something wrong with how I'm getting 'lastObject' or removing objects from array?

Upvotes: 1

Views: 510

Answers (2)

Sean X. Yu
Sean X. Yu

Reputation: 123

This seems to be a cacheing problem with multiple versions of emberjs loaded within the browser window context, as similar to the answer to this question: emberjs getEach method does not work as expected

I resolved problem by clearing browser history and rails precompiled tmp files.

Upvotes: 0

intuitivepixel
intuitivepixel

Reputation: 23322

Maybe you should do it this way. See here for a working jsbin.

while (this.get('clickViews.lastObject') !== undefined) {
  // perform some actions to last
  this.get('clickViews').removeObject(this.get('clickViews.lastObject'));
}

Hope it helps.

Upvotes: 0

Related Questions