As the title, on selectize, how can I disabled typing except Backspace key.
It will be allowed to:
It will NOT be allowed to:
I have read the API document but I can't found the solution. Any suggestions.
Here mine:
var $select = $('#tags').selectize({
maxItems: 5,
persist: false,
createOnBlur: true,
create: true,
});
UPDATE:
I found the solution by my own
$select[0].selectize.$control_input.on('keydown', function(e) {
var key = e.charCode || e.keyCode;
if(key == 8 )
return true;
else
e.preventDefault();
});
While the way you did it works, the proper way to prevent item addition is to use create: false
:
var $select = $('#tags').selectize({
maxItems: 5,
persist: false,
create: false
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With