Describe:
Select2 plug-in in IE, when the page is loaded and will automatically focus, pop-up should be clicked input will have a prompt.
Reason:
In the Select2 source code in the 1849th row or so, there is a listen to the input event codes, as follows:
this.$selection.on(‘keyup.search input‘‘.select2-search--inline‘,function (evt) { self.handleSearch(evt);});
You can see that this is using the HTML5 input event to listen for changes in the value of input, without using events such as the traditional change or KeyDown.
The reason for this is that the input event has a bug in IE. In IE, if an input has the placeholder attribute, IE will automatically trigger the input event for this, which will not occur in other browsers.
Solution Solutions
Write a compatibility method for IE, replace the input event with the KeyDown event when judging as ie.
varIsie = ( function () { varUA = Window.navigator.userAgent.toLowerCase ();if(Ua.indexof ("MSIE") >0|| Ua.indexof ("Trident") >0) {return true; }Else{return false; }}());varInput_event =!isie?' input ':' KeyDown '; this.$selection. On (' Keyup.search '+input_event,'. Select2-search--inline ', function (evt) { Self. Handlesearch (evt);});
Article FOREVERCJL
Article original CSDN Link: www.foreverpx.cn
Reprint please indicate the source.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Select2 plug-ins ie under autofocus bug resolution method