Created
October 29, 2015 22:07
-
-
Save bndw/861c0ad852fafb178cb7 to your computer and use it in GitHub Desktop.
ember select-box component
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.Component.extend({ | |
content: null, | |
selectedValue: null, | |
didInitAttrs(attrs) { | |
this._super(...arguments); | |
if (!this.get('content')) { | |
this.set('content', []); | |
} | |
}, | |
actions: { | |
change() { | |
const selectedEl = this.$('select')[0]; | |
const selectedIndex = selectedEl.selectedIndex; | |
const content = this.get('content'); | |
const selected = content[selectedIndex]; | |
this.set('selectedValue', selected.value); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment