Last active
April 1, 2016 21:52
-
-
Save offirgolan/b972368d3a07da5dba8986c39462168f to your computer and use it in GitHub Desktop.
New Twiddle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
import CRUD from '../mixins/crud'; | |
const { computed } = Ember; | |
export default Ember.Component.extend(CRUD, { | |
validations: computed(function() { | |
this._super(); // this is actually pointing to CRUD.actions.save instead of parent.validations | |
return {}; | |
}), | |
init() { | |
this._super(...arguments); | |
this.set('emitted', []); | |
}, | |
actions: { | |
save() { | |
// Get validations object which calls _super. | |
// _super should return the parent validation | |
// object but instead it calls the save action in | |
// the CRUD mixin | |
const validations = this.get('validations'); | |
this.emitted.pushObject('[my-component] save'); | |
this._super(...arguments); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default Ember.Mixin.create({ | |
actions: { | |
save(){ | |
this.emitted.pushObject('[crud mixin] save'); | |
} | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.7.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember.debug.js", | |
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.4.3/ember-data.js", | |
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.4.3/ember-template-compiler.js" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment