Skip to content

Instantly share code, notes, and snippets.

View chaoszcat's full-sized avatar
🎯
Focusing

Lionel Chan chaoszcat

🎯
Focusing
  • Singapore
View GitHub Profile
@orientalperil
orientalperil / title.js
Created November 6, 2012 21:22
SelectWithOptgroups: a subclass of Ember.Select
App.SelectWithOptgroups = Ember.Select.extend({
// A version of Ember.Select that supports optgroup tags.
// content can contain objects that represent the options or the optgroups
// Example of an optgroup object:
// Ember.Object.create({
// optgroup_label: 'foo',
// content: [Ember.Object.create({label: 'First Name', value: 'first_name'}), Ember.Object.create({label: 'Last Name', value: 'last_name'})]
// })
defaultTemplate: Ember.Handlebars.compile('{{#if view.prompt}}<option>{{view.prompt}}</option>{{/if}}{{#each view.content}}{{#if optgroup_label}}<optgroup {{bindAttr label="optgroup_label"}}>{{#each content}}{{view Ember.SelectOption contentBinding="this"}}{{/each}}</optgroup>{{else}}{{view Ember.SelectOption contentBinding="this"}}{{/if}}{{/each}}'),
options: function() {