Sam*_*met 5 jquery jquery-ui autocomplete placeholder
我正在使用jQuery UI自动完成组合框小部件.当我在我的组合框中添加占位符时,默认情况下会打开自动完成框.
这仅在IE10及更高版本上发生.
这是我的代码:
_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'));
},
Run Code Online (Sandbox Code Playgroud)
我们注意到问题是通过实际聚焦组合框来解决的.
一旦组合框被聚焦,自动完成框就消失了,当组合框失去焦点时它仍然保持这种状态.
所以,我们的解决方案有点黑客,我们添加了一个.focus()后跟一个.blur():
_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'));
this.input.focus().blur();
//^^^^^^^^^^^^^^^^^^^^^^^^^^ Voila!
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1947 次 |
| 最近记录: |