ember.js - Set default (selected) option Ember 1.13.11 -


sort version:

why work: <option disabled={{option.isselected}}>

but not this: <option selected={{option.isselected}}>

long version:

this more me learning how ember works getting working, since there lots of working examples already.

i'm trying set default selected option in select menu. looks there different ways of doing , recommended method changing.

i'm working in ember 1.13.11 want ember 2.0 compatible.

i haven't found ember 2.0 compatible method didn't involve template helper selected attribute. can create true/false value property on controller. know i'm doing right because disabled works properly. why fail select?

template call:

{{version-details item=version status=version.status}} 

component controller:

import ember 'ember';  export default ember.component.extend({   tagname: 'select',   options: ember.computed('status', function() {     var statusoptions = ['beta', 'current', 'future', 'retired-beta', 'retired', 'unknown'];     var selected = this.get('status');     var optionsdata = [];     statusoptions.foreach( function(status){       var isselected = (selected == status);       optionsdata.push({ status: status, isselected: isselected });     })     return optionsdata;   }),   setaction: '', }); 

component:

{{#each options |option|}}   <option selected={{option.isselected}}>{{option.status}}</option> {{/each}} 

as @blessenm points out. work.

i think couldn't tell working because browser remembering , selecting value last time visited page.


Comments

Popular posts from this blog

ios - UITEXTFIELD InputView Uipicker not working in swift -

Hatching array of circles in AutoCAD using c# -