Last active
June 26, 2016 13:20
-
-
Save mrosata/78532bea9f9e51f647e5cd0b64da749c to your computer and use it in GitHub Desktop.
Disabled Button Example
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({ | |
| isDisabled: false, | |
| pureBoolean: Em.computed('isDisabled', function() { | |
| return !this.get('isDisabled'); | |
| }), | |
| actions: { | |
| makeDisabled() { | |
| this.set('isDisabled', true); | |
| }, | |
| // this resets example | |
| resetExample() { | |
| this.set('isDisabled', false); | |
| } | |
| } | |
| }); |
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.9.3", | |
| "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.4.5", | |
| "ember-data": "2.1.0", | |
| "ember-template-compiler": "2.4.5" | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was a Twiddle done to demo an answer that was on StackOverflow. It is a workaround to returning null from a JavaScript function just to be able to make a
disabledproperty function correctly in a template. It's a small thing but it separates concerns because now the JavaScript can return any falsey value and get the same effect as returning null to the property used to determine the buttonsdisabledstate.