Hi,
I'm new to select2 and want to change the MinimumInputLength behavior to remove the "Please enter x or more characters" prompt.
I *think* the right way to do this is a custom decorator, something like:
function MyMinimumInputLength(decorated, $e, options) {
this.minimumInputLength = options.get('minimumInputLength');
decorated.call(this, $e, options);
}
MyMinimumInputLength.prototype.query = function(decorated, params, callback) {
if ((params.term || '').length >= this.minimumInputLength) {
decorated.call(this, params, callback);
}
};
What I don't understand is, how do I get a reference to the default DataAdapter so I can add my decorator to it? The examples I've seen involve a custom DataAdapter, explicitly assigned to options.dataAdapter when the select2 is initialized. But that seems like overkill (plus I would have to manually apply all the other decorators I want, replicating existing logic). I want to do something like intercept the options after all defaults have been applied, take the value that Defaults.prototype.apply assigned to options.dataAdapter, and wrap it in my decorator. Is there a way to do that?
Thanks!
PS Even if there's a different way to remove that prompt, I'd like to understand the underlying question of how to decorate a non-custom adapter. Ta!