Skip to content

Instantly share code, notes, and snippets.

@siva-sundar
Last active March 6, 2016 10:23
Show Gist options
  • Save siva-sundar/c299db9c8d5bf5e0aa52 to your computer and use it in GitHub Desktop.
Save siva-sundar/c299db9c8d5bf5e0aa52 to your computer and use it in GitHub Desktop.
didUpdateAttrs not called
import Ember from 'ember';
export default Ember.Controller.extend({
init() {
this._super(...arguments);
this.set('model', Ember.A());
},
actions:{
addObject() {
this.get('model').pushObject({num: Math.random()});
}
}
});
<h2>didUpdateAttrs not called on array modifications</h2>
<br>
<br>
{{my-component model=model}}
<br>
<button {{action 'addObject'}}>
add </button>
{{outlet}}
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
didUpdateAttrs() {
this._super(...arguments);
console.log('updateAttrs');
}
});
model.length = {{model.length}}
<br>
<br>
Check console for `updateAttrs` while adding
{{yield}}
{
"version": "0.6.1",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "canary",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
"ember-template-compiler": "canary"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment