IE-select2总是获得焦点
IE - select2 always gets the focus
本文关键字:焦点 IE-select2 更新时间:2023-09-26
我的网站使用select2插件。在IE中,遇到的问题是它总是将焦点设置在select2帧上。
<select class="form-control" name="categories[]" id="inputCate" multiple="multiple">
//JS-
$(document).ready(function(){
var data = [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }];
$("#inputCate").select2({
data: data,
maximumSelectionLength: 2,
placeholder: "Chuyên mục"
});
});
Fiddle
IE中有一个错误:应用占位符文本时发生输入事件。因此,您可以:a) 删除占位符选项b) 替换select2.js
this.$selection.on('input', '.select2-search--inline', function (evt) {
// Unbind the duplicated `keyup` event
self.$selection.off('keyup.search');
});
this.$selection.on('keyup.search input', '.select2-search--inline',
function (evt) {
self.handleSearch(evt);
})
带有
this.$selection.on('keyup.search', '.select2-search--inline',
function (evt) {
self.handleSearch(evt);
});
尝试使用最新版本Select2 v4.0.1
修复了许多错误
这是IE占位符错误。当js替换占位符IE时,设置焦点。我对jQuery和Select2 4.0.0 的糟糕解决方案
fixIePlaceholderSelect2 = function(select) {
var placeholderFix = select.parent().find('.placeholder_ie_fix');
if(select.val())
placeholderFix.addClass('hide');
placeholderFix.on("click", function () {
select.select2("open");
$(this).addClass('hide');
});
select.on("select2:open", function () {
if(!select.val())
placeholderFix.addClass('hide');
});
select.on("select2:close", function () {
placeholderFix.removeClass('hide');
});
};
fixIePlaceholderSelect2(
$('select[name=services]')
);
.placeholder_ie_fix {
position: absolute;
margin-top: -9px;
cursor: pointer;
}
.placeholder_ie_fix.hide {
display: none;
}
<div class="placeholder_ie_fix">My placeholder</div>
<select name="services" class="set_fix" multiple>
<option>234</option>
</select>
如果您避免占位符中的重音符号,它可以很好地工作。
正如@alexander nekrasov所说,问题出在占位符上,但前提是它包含重音符号。尝试placeholder: "Chuyen mục"
,看看它是否有效。需要一些测试,但它对我有效。
相关文章:
- 后焦点更改为IE 11中的地址栏,而不是转移到表单中的下一个控件
- IE-select2总是获得焦点
- IE Onblur和焦点问题
- 如何阻止IE(Internet Explorer)中的内联块元素获得焦点
- IE 焦点事件在 ajax 加载后随机失败
- 如何通过单击按钮自动打开子窗口作为焦点窗口(IE)
- 将焦点放在 IE 中的输入框上
- 是否可以在选择之前找出哪个选择选项在IE中具有焦点
- 提交图像按钮的焦点在IE 8中未突出显示
- IE在焦点后跳转到文本区域的开头
- jQuery.is(“:焦点”)不;在IE以外的浏览器中,无法识别焦点在复选框上
- JavaScript Alert()未在IE中获得焦点
- select2在mozilla中可用,但在IE中无效
- 在焦点上打开select2
- IE与'焦点'事件
- 为什么Angular UI按钮在Chrome中的焦点边框与在IE中的焦点边框不同?
- 如何在IE中重新获得ajax下拉元素的焦点
- 如何在标签模式下将焦点设置为Select2 4.0
- IE 11带焦点选择,单击后焦点丢失
- IE-10使用jquery在文本框上设置焦点时光标的位置