Placeholder opens jQuery UI autocomplete combobox on page load (IE10)

I am using jQuery UI autocomplete combobox widget. When I add placeholders to my lists, autocomplete fields open by default.

This only happens for IE10 and later .

This is my code:

_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')); }, 
+5
source share
2 answers

We noticed that the problem was solved by focusing drop-down lists.

After the combo box is focused, the autocomplete field disappeared, and it remained so when the drop-down field lost focus.

So our solution was a bit .focus() , we added .focus() and then .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! }, 
+6
source

We had the same problem in IE10 +, but only when we add a placeholder with special characters (German "Umlaute").

Seckin's solution also solved our problem - after 1 day of Google ;-)

Tried to vote for an answer, but as a newbie, I have no reputation for this ...

 _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(); }, 
0
source

Source: https://habr.com/ru/post/1211826/


All Articles