Created
April 2, 2019 05:09
-
-
Save thoov/d24058c256a364d5b15f066e2129e687 to your computer and use it in GitHub Desktop.
Disabled Button Example
This file contains 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 { computed } from '@ember/object'; | |
export default Ember.Component.extend({ | |
childInputs: null, | |
init() { | |
this._super(...arguments); | |
this.childInputs = Ember.A([ { isValid: false }, { isValid: false } ]); | |
}, | |
disableButton: computed('childInputs.@each.isValid', function() { | |
let inputs = this.childInputs; | |
let allInputTrue = inputs.every((i) => i.isValid === true); | |
return !allInputTrue; | |
}), | |
actions: { | |
validityChanged(idx, value) { | |
this.get('childInputs').replace(idx, 1, Ember.A([ {isValid: value }])); | |
} | |
} | |
}); |
This file contains 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 { computed } from '@ember/object'; | |
export default Ember.Component.extend({ | |
inputValue: null, | |
didInsertElement() { | |
this._super(...arguments); | |
this.validityChanged(this.isValid); | |
}, | |
isValid: computed('inputValue', function() { | |
return parseInt(this.inputValue, 10) > 10; | |
}) | |
}); |
This file contains 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 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.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment