Skip to content

Instantly share code, notes, and snippets.

@HenryVonfire
Last active September 29, 2015 08:22
Show Gist options
  • Save HenryVonfire/6ce698556af7b8615bc4 to your computer and use it in GitHub Desktop.
Save HenryVonfire/6ce698556af7b8615bc4 to your computer and use it in GitHub Desktop.
Easy Select
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Easy Select'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{easy-select}}
<br>
<br>
import Ember from 'ember';
export default Ember.Component.extend({
value: 'no-value selected',
listValues: ['value1','value2','value3','value4'],
actions:{
selectValue(e){
const value = e.target.value;
if(value !== 'default'){
this.set('value',value);
} else {
this.set('value','no-value selected');
}
},
}
});
<select name="select" onchange={{action 'selectValue'}}>
<option value="default" selected>no-value</option>
{{#each listValues as |item|}}
<option value={{item}}>{{item}}</option>
{{/each}}
</select>
<p>The value selected is: {{value}}</p>
{
"version": "0.4.11",
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/1.13.11/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/1.13.9/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment