Skip to content

Commit

Permalink
[BUGFIX BETA] Fix initial selection for select with optgroup
Browse files Browse the repository at this point in the history
  • Loading branch information
kamalakannan.n committed May 14, 2015
1 parent f2540bf commit f3a8792
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/ember-htmlbars/lib/templates/select.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{{#if view.prompt}}<option value="">{{view.prompt}}</option>{{/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}}<option value="">{{view.prompt}}</option>{{/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}}
19 changes: 19 additions & 0 deletions packages/ember-views/tests/views/select_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down

0 comments on commit f3a8792

Please sign in to comment.