[英]selectize.js - how can I disable the flashing cursor after the selected item?
我正在使用selectize.js来设置文本框的样式,并且工作正常。
$("select[name='somename']").selectize({
valueField: 'id',
labelField: 'name',
searchField: 'name',
options: selectableThings,
render: {
option: function(item, escape) {
return render(someTemplate, item);
},
item: function(item, escape) {
return render(someTemplate, item);
}
}
});
但是,我的项目范围有限,并且不希望一直启用光标(闪烁 |)。 我已经搜索了 API 文档和源代码,但找不到任何明显的东西。
是否有内置的东西来禁用闪烁的光标?
编辑最初将此作为“禁用输入”,但看起来光标不能用于输入(并且禁用输入仍然显示光标)。
选择尚未特别设计用于选择装饰器。 光标来自允许用户减少选项的<input>
元素。 隐藏输入会在用户键入时产生奇怪的行为。 此外,当控件为空时,输入用于显示占位符文本。
从技术上讲,您可以使用 CSS 隐藏光标(和输入):
/* option a: make transparent */
.selectize-input input {
color: transparent !important;
}
/* option b: position off-screen */
.selectize-input input {
position: absolute !important;
top: -9999px;
left: -9999px;
}
但同样,这会让人感觉很时髦。 我会考虑编写一个decorator_only
插件来禁用键盘处理,但这不是当务之急。
您还可以使用 CSS 文本缩进将光标移出屏幕:
input {
text-indent: -100px;
}
如果要禁用 selectize 的键盘功能,只需将其设置为readonly
。
$(select).selectize(options);
select.parentNode.querySelector('input').readOnly = true;
如果要在将 selectize 用于简单的单项选择下拉列表时删除闪烁的输入光标,则需要将被 selectize HTML 替换的原始 select 元素的颜色设置为透明。
#myform select {
color: transparent;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.