2

At the moment I am using the {{view Ember.Select}} method to create a grouped select field quite easily, as follows:

{{view Ember.Select 
    name="car_manufacturer"
    contentBinding="car_manufacturers"
    optionGroupPath="country"
    optionValuePath="content.val"
    optionLabelPath="content.label"
}}

My question is, is there any way by which Ember.Select can create a select field that doesn't wrap the <option> tags for specific group name(s) in the <optgroup> tag?

e.g, produce markup like this:

<select>
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>  
    ...
    <optgroup label="Germany">
        <option value="mercedes">Mercedes</option>
        <option value="audi">Audi</option>
        ...
    </optgroup>
    <optgroup label="Korea">
        <option value="kia">Kia</option>
        ...
    </optgroup>
</select> 
1
  • 1
    have you found any solutions or workarounds? I'm having the same issue.
    – Nick G.
    Feb 21, 2014 at 23:14

1 Answer 1

0

Sort the data beforehand and send it into the option without the group path.

carsByCountry: function(){
  return this.sortBy('country'); 
}.property()

http://emberjs.jsbin.com/IRIpAYo/1/edit

2
  • That completely misses the point. Your jsbin doesn't create anything like what @TimCromwell was asking for.
    – Nick G.
    Feb 21, 2014 at 23:13
  • 2
    I'm sorry I've offended you so much by attempting to help, his question is quite ambiguous, he asked "is there any way by which Ember.Select can create a select field that doesn't wrap the <option> tags for specific group name(s) in the <optgroup> tag" I provided a way where his results were ordered by group, and doesn't wrap the <option> tags in the <optgroup> tag.
    – Kingpin2k
    Feb 21, 2014 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.