Skip to content

Instantly share code, notes, and snippets.

@peterwmwong
Created November 7, 2012 20:29
Show Gist options
  • Save peterwmwong/4034205 to your computer and use it in GitHub Desktop.
Save peterwmwong/4034205 to your computer and use it in GitHub Desktop.
define( function() {
return {
initialize: function() {
this.$el
.attr( 'name', this.options.property )
.addClass( this.options.property );
},
render_el: function(__) { return [
this.options.label && __( '.label', this.options.label ),
__('.selectWrap',
__('select',
__('option', {value: 'Select One'}, 'Select One'),
_.map( this.options.options, function(v,k){
return __('option', {value:k}, v);
})
)
)
]; },
after_render: function() {
this.$select = this.$("select");
this.$select.val(this.model.get(this.options.property));
},
events: {
'change select': function(e) {
this.model.set(
this.options.property,
this.$select.val(),
{forceUpdate: true}
);
}
}
};
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment