-
-
Save bogn/6291691 to your computer and use it in GitHub Desktop.
Select2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Select2 | |
* | |
* Renders Select2 - jQuery based replacement for select boxes | |
* | |
* Simply pass a 'config' object on your schema, with any options to pass into Select2. | |
* See http://ivaynberg.github.com/select2/#documentation | |
*/ | |
Backbone.Form.editors.Select2 = Backbone.Form.editors.Base.extend({ | |
/** | |
* @param {Object} options.schema.config Options to pass to select2. See http://ivaynberg.github.com/select2/#documentation | |
*/ | |
initialize: function(options) { | |
Backbone.Form.editors.Base.prototype.initialize.call(this, options); | |
var schema = this.schema; | |
this.config = schema.config || {}; | |
}, | |
render: function() { | |
var self = this; | |
setTimeout(function() { | |
self.$el.select2(self.config); | |
}, 0); | |
return this; | |
}, | |
getValue: function() { | |
return this.$el.val(); | |
}, | |
setValue: function(val) { | |
this.$el.val(val); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment