Skip to content

Instantly share code, notes, and snippets.

@kumkanillam
Last active March 8, 2017 22:01
Show Gist options
  • Save kumkanillam/5a63839b643d23d8fb06f399253ca68b to your computer and use it in GitHub Desktop.
Save kumkanillam/5a63839b643d23d8fb06f399253ca68b to your computer and use it in GitHub Desktop.
import Ember from 'ember';
export default Ember.Component.extend({
didReceiveAttrs(options){
this._super(...arguments);
//this will run both initial render and rerender.
//For initial rendering alone options.oldAttrs will not be available
},
didUpdateAttrs(options){
this._super(...arguments);
//this will run only for the rerender
if(options.oldAttrs.selectedOptionId.value !== options.newAttrs.selectedOptionId.value) {
this.send('triggerOptionChangeEvent');
}
},
actions:{
triggerOptionChangeEvent(){
console.log('triggerOptionChangeEvent ',this.get('selectedOptionId'));
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
selectedOptionId:1,
actions:{
changeOption(){
this.set('selectedOptionId',2);
console.log(' '+this.get('selectedOptionId'));
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
});
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
});
export default Router;
{{parent-component }}
{{outlet}}
{{selectedOptionId}}
{{yield}}
{{my-table selectedOptionId=selectedOptionId}}
<button {{action 'changeOption'}}> Change Option </button>
{{yield}}
{
"version": "0.10.4",
"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.7.0",
"ember-data": "2.7.0",
"ember-template-compiler": "2.7.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment