Created
March 14, 2013 12:49
-
-
Save powmedia/5161061 to your computer and use it in GitHub Desktop.
This file contains 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
"Uncaught query function not defined for Select2 " getting this error . i am passing backbone collection as options here is the code avatar:{ type: 'Select2', options: new avatars, title:'Matter' }, and my avatar model has tostring function ...