Even after reading a lot of doc, I'm still not able to accomplish this simple task;
I have a select view in my template:
{{view Ember.Select id="id_diff" contentBinding="difficulties" optionValuePath="content.id" optionLabelPath="content.title" valueBinding="selectedDifficulty"}}
this select is filled correctly with this data: {id: 1, title: easy}{id: 2, title: medium}{id: 3, title: hard}
I just want to set the default value to "medium" instead of easy that is the default value now; how can I do this?
The Controller:
Gmcontrolpanel.InsertActivityController = Em.Controller.extend({
difficulties: function() {
var difficulties = [];
difficulties = this.get('store').find('difficulty');
return difficulties;
}.property(),
changeDifImg: function() {
jQuery('.diff-icon').animate({'opacity': 0}, 300);
jQuery('#diff-img' + jQuery('#id_diff').val()).animate({'opacity': 1}, 300);
}.observes('selectedDifficulty'),
startValue: null
});
The ChangeDifImg property is used to change the associated difficulty icon when user changes the value in the select;
(in the template:
{{#each difficulty in difficulties}}
<img class="diff-icon" id="diff-img{{unbound difficulty.id}}" src="{{unbound "difficulty.link"}}" style="opacity: 0" />
{{/each}}
this creates one immage for every difficulty and set them all invisible; then when the user selects a value in the Select, the changeDifImg property shows the correct icon