Skip to content

Instantly share code, notes, and snippets.

@HusseinMorsy
Last active November 14, 2015 20:58
Show Gist options
  • Select an option

  • Save HusseinMorsy/6f97a3924569ff9d63ba to your computer and use it in GitHub Desktop.

Select an option

Save HusseinMorsy/6f97a3924569ff9d63ba to your computer and use it in GitHub Desktop.
select
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle',
therapists: [ {id: 1, name: "Elli"}, {id: 2, name:"Patricia"}],
therapist: {id: 1, name: "Elli"},
actions: {
selectTherapist(therapist_id){
this.set('therapist', this.therapists[therapist_id-1])
}
}
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
<div>Active Therapist: <b>{{therapist.name}}</b></div>
<select onchange={{action 'selectTherapist' value="target.value"}}>
{{#each therapists as |t|}}
<option value={{t.id}}>{{t.name}}</option>
{{/each}}
</select>
{{outlet}}
<br>
<br>
{
"version": "0.4.16",
"EmberENV": {
"FEATURES": {}
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember.debug.js",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.1.0/ember-data.js",
"ember-template-compiler": "https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.1.0/ember-template-compiler.js"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment