占位符在页面加载时打开jQuery UI自动完成组合框(IE10)
我正在使用jQueryUI自动完成组合框小部件。在组合框上添加占位符时,默认情况下会打开自动完成框 这只在IE10及更高版本上发生 这是我的代码:占位符在页面加载时打开jQuery UI自动完成组合框(IE10),jquery,jquery-ui,autocomplete,placeholder,Jquery,Jquery Ui,Autocomplete,Placeholder,我正在使用jQueryUI自动完成组合框小部件。在组合框上添加占位符时,默认情况下会打开自动完成框 这只在IE10及更高版本上发生 这是我的代码: _create: function () { this.wrapper = $("<span>") .addClass("custom-combobox") .insertAfter(this.element); this.element.h
_create: function () {
this.wrapper = $("<span>")
.addClass("custom-combobox")
.insertAfter(this.element);
this.element.hide();
this._createAutocomplete();
this._createShowAllButton();
this.input.attr("placeholder", this.element.attr('placeholder'));
},
\u创建:函数(){
this.wrapper=$(“”)
.addClass(“自定义组合框”)
.insertAfter(此.element);
this.element.hide();
这是。_createAutocomplete();
这是。_createShowAllButton();
this.input.attr(“占位符”,this.element.attr(“占位符”);
},
我们注意到,通过实际聚焦组合框,问题得到了解决
一旦组合框聚焦,自动完成框就消失了,当组合框失去焦点时,它仍然保持这种状态
因此,我们的解决方案有点老套,我们添加了一个.focus()
,后面是一个.blur()
:
\u创建:函数(){
this.wrapper=$(“”)
.addClass(“自定义组合框”)
.insertAfter(此.element);
this.element.hide();
这是。_createAutocomplete();
这是。_createShowAllButton();
this.input.attr(“占位符”,this.element.attr(“占位符”);
this.input.focus().blur();
//^^^^^^^^^^^^^^^^^^^^^^^^^^瞧!
},
我们在IE10+中也遇到了同样的问题,但就在我们添加带有特殊字符的占位符时(德语“Umlaute”)
塞金的解决方案也解决了我们的问题——经过一天的谷歌努力;-)
我试着投票支持这个答案,但作为一个新手,我没有这样做的名声
_create: function () {
this.wrapper = $("<span>")
.addClass("custom-combobox")
.insertAfter(this.element);
this.element.hide();
this._createAutocomplete();
this._createShowAllButton();
this.input.attr( "placeholder", 'Bitte wählen' );
this.input.focus().blur();
},
\u创建:函数(){
this.wrapper=$(“”)
.addClass(“自定义组合框”)
.insertAfter(此.element);
this.element.hide();
这是。_createAutocomplete();
这是。_createShowAllButton();
attr(“占位符”,“bite wählen”);
this.input.focus().blur();
},
请写一些关于这个问题的详细信息。我真的很高兴它有帮助!感谢@oekokroete的信用,因为它是相同的解决方案;我不认为这应该是一个答案,欢迎您添加此作为对现有答案的评论。
_create: function () {
this.wrapper = $("<span>")
.addClass("custom-combobox")
.insertAfter(this.element);
this.element.hide();
this._createAutocomplete();
this._createShowAllButton();
this.input.attr( "placeholder", 'Bitte wählen' );
this.input.focus().blur();
},