I want to support the MaximumInputLength
decorator for my custom Select2 Data Adapter. In my custom data adapter, the Utils.Decorate()
call does not do anything.
Looking at this gist, I could call the Decorator function in the same place where I initialize select2()
, but that seems icky and not DRY, as I want to initialize many of these Select elements.
In order to enable minimum input for ALL instances of MyDataAdapter, is it possible to decorate that adapter from the adapter itself? Is there a better way to do this?
My select2()
call:
$('select').select2({
dataAdapter: MyDataAdapter,
minimumInputLength: 2
});
MyDataAdapter
(sans dependencies):
define([...], function(Utils, MinimumInputLength, ArrayAdapter){
function MyDataAdapter($element, options) {
this.$element = $element;
this.options = options;
MyDataAdapter.__super__.constructor.call(this, $element, options);
}
Utils.Extend(MyDataAdapter, ArrayAdapter);
Utils.Decorate(MyDataAdapter, MinimumInputLength); <-- does nothing
MyDataAdapter.prototype.query = function(params, callback) {
console.log('query!');
};
return MyDataAdapter;
});
Utils.Decorate()
call? – Berkeley