-
-
Save pixelhandler/d0c78546ca4c647dd06df8fb55b6dd87 to your computer and use it in GitHub Desktop.
Checked
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 layout from '../templates/components/toggle-pill'; | |
const CHECKED = 'checked'; | |
export default Ember.Component.extend({ | |
layout, | |
inputId: 123, | |
// Component properties | |
checked: false, | |
// Lifecycle methods | |
didInsertElement() { | |
this.cacheDOMElements(); | |
}, | |
// Ember controlled events | |
click(e) { | |
// A click on the label will actually trigger a separate click event | |
// on the input. So only check for clicks on the input. | |
if (e.target === this.inputEl) { | |
console.log(this.get(CHECKED)); | |
this.get('onToggle')(!this.get(CHECKED)); | |
} | |
}, | |
// Other methods | |
cacheDOMElements() { | |
this.inputEl = this.$('input')[0]; | |
this.labelEl = this.$('label')[0]; | |
} | |
}); | |
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', | |
isChecked: false, | |
actions: { | |
pillToggled(checked) { | |
console.log('TOGGLED'); | |
console.debug('isChecked', this.get('isChecked')); | |
this.toggleProperty('isChecked'); | |
console.debug('isChecked', this.get('isChecked')); | |
}, | |
toggle() { | |
this.toggleProperty('isChecked'); | |
} | |
} | |
}); |
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.11.0", | |
"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.10.2", | |
"ember-data": "2.11.0", | |
"ember-template-compiler": "2.10.2", | |
"ember-testing": "2.10.2" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment