Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery UI Autocomplete automatically fire (IE)

I have a very bad problem with JQuery Autocomplete and the Internet Explorer.

First I have a input field with a special char value like:

<div class="ui-widget">
    <label for="tags">Tags: </label>
    <input id="tags" value="Häskell">
</div>

Then my JQuery UI Autocomplete Code looks like

$(function() {
        var availableTags = [
            "ActionScript",
            "AppleScript",
            "Asp",
            "BASIC",
            "C",
            "C++",
            "Clojure",
            "COBOL",
            "ColdFusion",
            "Erlang",
            "Fortran",
            "Groovy",
            "Häskell",
            "Java",
            "JavaScript",
            "Lisp",
            "Perl",
            "PHP",
            "Python",
            "Ruby",
            "Scala",
            "Scheme"
        ];
        $( "#tags" ).autocomplete({
            source: availableTags
        });
    });

Now when i visit the site with the Internet Explorer, the autocomplete automatically fire and show me the entry "Häskell". (You also can press F5 to reproduce the bug) But that only happens when the input field value has a special char like ä, ö, ...

I also found a Bug Ticket http://bugs.jqueryui.com/ticket/9796#no1

Can somebody help me please?

Big thanks!

like image 568
Flash01 Avatar asked Mar 21 '23 06:03

Flash01


1 Answers

To prevent such event you should a bit modify jquery ui (it is real bug of IE and partially jquery). Problem is in next feature. IE rises event "input" where another browers does not rise it. before modifying this function has next view:

input:function(e) {
  if (r) {
    r =! 1, e.preventDefault();
    return;
  }
  this._searchTimeout(e)
}


You should modify it to next
input:function(e) {
  if (r || typeof(r) == "undefined") {
    r =! 1, e.preventDefault();
    return;
  }
  this._searchTimeout(e)
}
like image 176
Vasyl Avatar answered Mar 28 '23 22:03

Vasyl