Skip to content

Instantly share code, notes, and snippets.

@HaNdTriX
Last active April 19, 2018 17:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HaNdTriX/33c487b475af1b57838d to your computer and use it in GitHub Desktop.
Save HaNdTriX/33c487b475af1b57838d to your computer and use it in GitHub Desktop.
Selectize Plugin to allow to set a maxlength
Selectize.define('inputMaxlength', function(options) {
var self = this;
this.setup = (function() {
var original = self.setup;
return function() {
original.apply(this, arguments);
this.$control_input.attr('maxlength', this.settings.inputMaxlength);
};
})();
});
@HaNdTriX
Copy link
Author

Usage

$('.my-element-selector').selectize({
  plugins: ['inputMaxlength'],
  inputMaxlength: 20
})

@kid-three
Copy link

how do you install this plugin?

I tried adding a new folder under selectize>plugins>inputMaxLength and dropping th efile there and renaming it plugin.js

I keep getting Unable to find "inputMaxlength" plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment