I have searched but not clear how it works.
Its built-in or need customization?
If you build your select with html, use the :
disabled="disabled"
Otherwise you can "disable()" it via the js API.
after disable input send empty array ! why
Hi, try this plugin
Selectize.define('readOnly', function () {
var self = this;
self.setup = (function () {
var original = self.setup;
return function () {
original.apply(self, arguments);
if (self.$input.is('[readonly]')) {
self.$control_input.prop('readonly', true);
self.$control.off();
self.$control.css('background-color', '#e9ecef');
self.$control.find('.remove-single').remove();
self.$control.find('.remove').remove();
}
};
})();
});
Readonly in selectize is a call to "lock" method. Eg.:
$('#yourElement')[0].selectize.lock();
Dynamically is possible to unlock too:
$('#yourElement')[0].selectize.unlock();
Readonly in selectize is a call to "lock" method. Eg.:
$('#yourElement')[0].selectize.lock();
Yes.
Or something like $('.selectized:read-only').each(function (input) { input.selectize.lock(); });, in case we want this to be automatic for any selectized element of the page (beware: do not put this into a widget instantiated multiple times, since it will run the .each loop too many times unnecessarily.
Still, would be nice some default way to do it; like the plugin above, just without removing the markup (but just adding a class to hide the remove-single and remove buttons) and allowing to use a custom background-color or style (adding a .readonly class to eventually customise in another theme/style).
Also, probably one or two unit-tests should be added to ensure it keeps working.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Most helpful comment
Hi, try this plugin