0
votes

This fiddle requires user to select option B , so it gives that message when other than B option is selected. Still, I need to set default option as B in select dropdown.

http://jsfiddle.net/fortm/YpEMH/

I tried this but seems not working for setting selectedName in SearchController ..

selectedName = this.get('model').objectAt('firstChild')
2

2 Answers

2
votes

You can set the selectedName controller property in the route's setupController hook:

setupController: function(controller, model) {
  controller.set('model', model);
  controller.set('selectedName', model.findProperty('firstName', 'B'));
}

That way when the route is rendered, the select will default to "B".

I updated the fiddle.

0
votes

Ember select now allows you to set a default value based on a controller property. See http://emberjs.com/api/classes/Ember.Select.html for more details but here is a summary:

App.TreesIndexController = Ember.ArrayController.extend({

  defaultTree: 'enzyme',
  treeTypes: ['enzyme', 'chembl']

});

{{view Ember.Select
       content=treeTypes
       prompt="Please select a target class"
       value=defaultTree}}

The option select would default to 'enzyme' in this example.