diff --git a/packages/ember-htmlbars/lib/templates/select.hbs b/packages/ember-htmlbars/lib/templates/select.hbs index 63f65ddab46..64f5912a0be 100644 --- a/packages/ember-htmlbars/lib/templates/select.hbs +++ b/packages/ember-htmlbars/lib/templates/select.hbs @@ -1 +1 @@ -{{#if view.prompt}}{{/if}}{{#if view.optionGroupPath}}{{#each view.groupedContent as |group|}}{{view view.groupView content=group.content label=group.label selection=view.selection multiple=view.multiple optionLabelPath=view.optionLabelPath optionValuePath=view.optionValuePath optionView=view.optionView}}{{/each}}{{else}}{{#each view.content as |item|}}{{view view.optionView content=item selection=view.selection parentValue=view.value multiple=view.multiple optionLabelPath=view.optionLabelPath optionValuePath=view.optionValuePath}}{{/each}}{{/if}} +{{#if view.prompt}}{{/if}}{{#if view.optionGroupPath}}{{#each view.groupedContent as |group|}}{{view view.groupView content=group.content label=group.label selection=view.selection value=view.value multiple=view.multiple optionLabelPath=view.optionLabelPath optionValuePath=view.optionValuePath optionView=view.optionView}}{{/each}}{{else}}{{#each view.content as |item|}}{{view view.optionView content=item selection=view.selection parentValue=view.value multiple=view.multiple optionLabelPath=view.optionLabelPath optionValuePath=view.optionValuePath}}{{/each}}{{/if}} diff --git a/packages/ember-views/tests/views/select_test.js b/packages/ember-views/tests/views/select_test.js index 9c463e2711f..e5fc1d8c0ca 100644 --- a/packages/ember-views/tests/views/select_test.js +++ b/packages/ember-views/tests/views/select_test.js @@ -497,6 +497,25 @@ QUnit.test("select with group doesn't break options", function() { deepEqual(select.get('selection'), content.get('firstObject')); }); +QUnit.test("select with group works for initial value", function() { + var content = Ember.A([ + { id: 1, firstName: 'Yehuda', organization: 'Tilde' }, + { id: 2, firstName: 'Tom', organization: 'Tilde' }, + { id: 3, firstName: 'Keith', organization: 'Envato' } + ]); + + run(function() { + select.set('content', content); + select.set('optionGroupPath', 'organization'); + select.set('optionValuePath', 'content.id'); + select.set('value', 2); + }); + + append(); + + equal(select.$().val(), 2, "Initial value is set properly"); +}); + QUnit.test("select with group observes its content", function() { var wycats = { firstName: 'Yehuda', organization: 'Tilde' }; var content = Ember.A([