admin管理员组文章数量:1388039
As the title, on selectize, how can I disabled typing except Backspace key.
It will be allowed to:
- Select item on dropdown.
- Delete selected items.
It will NOT be allowed to:
- Type or add any new items.
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();
});
As the title, on selectize, how can I disabled typing except Backspace key.
It will be allowed to:
- Select item on dropdown.
- Delete selected items.
It will NOT be allowed to:
- Type or add any new items.
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();
});
Share
Improve this question
edited Oct 5, 2016 at 6:30
TommyDo
asked Oct 5, 2016 at 5:02
TommyDoTommyDo
6738 silver badges25 bronze badges
1
- The solutions listed above didn't work But this is work! stackoverflow./a/30087408/20175904 – Evgenii St. Commented Oct 7, 2022 at 9:37
1 Answer
Reset to default 5While 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
});
本文标签: javascriptDisable typing on selectizeStack Overflow
版权声明:本文标题:javascript - Disable typing on selectize - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744486905a2608504.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论