Skip to content

Instantly share code, notes, and snippets.

@James1x0
Created December 15, 2016 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save James1x0/52a530ec82d2122c43b59d589d46cb46 to your computer and use it in GitHub Desktop.
Save James1x0/52a530ec82d2122c43b59d589d46cb46 to your computer and use it in GitHub Desktop.
updateattrs?
import Ember from 'ember';
export default Ember.Component.extend({
updates: Ember.A(),
didReceiveAttrs () {
this._super(...arguments);
this.get('updates').pushObject('didReceiveAttrs ' + new Date());
},
didUpdateAttrs () {
this._super(...arguments);
this.get('updates').pushObject('didReceiveAttrs ' + new Date());
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
arr: Ember.A([ 1, 2, 3 ]),
actions: {
triggerArrUpdate () {
this.get('arr').addObject(this.get('arr.lastObject') + 1);
}
}
});
Array: {{#each arr as |a|}}{{a}}{{/each}}<br />
<button type="button" {{action "triggerArrUpdate"}}>Trigger Attr Update</button>
{{x-test arr=arr}}
<ul>
{{#each updates as |u|}}
{{u}}
{{/each}}
</ul>
Array: {{#each arr as |a|}}{{a}}{{/each}}
{
"version": "0.10.6",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.9.0",
"ember-data": "2.9.0",
"ember-template-compiler": "2.9.0",
"ember-testing": "2.9.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment