Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#8847 closed bug (notabug)

Bug in autocomplete jquery-ui-1.9.1

Reported by: domcars0 Owned by:
Priority: minor Milestone: 1.10.0
Component: ui.autocomplete Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

I think there is a bug in the jquery-ui-1.9.1 autocomplete plugin. The ui parameter is not passed to the close or change event... Here is your demo code with just the two events ... (change event is not call in google chrome ?)

<!doctype html>
<html lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<script src="/scripts/jQuery/jquery.min.js" type="text/javascript"></script>
<title>jQuery UI Autocomplete - bug change/close : </title>
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.8.2.js"></script>
    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
    <link rel="stylesheet" href="/resources/demos/style.css" -->
<script type="text/javascript">
    $(function() {
        var availableTags = [
            "ActionScript",
            "AppleScript",
            "Asp",
            "BASIC",
            "C",
            "C++",
            "Clojure",
            "COBOL",
            "ColdFusion",
            "Erlang",
            "Fortran",
            "Groovy",
            "Haskell",
            "Java",
            "JavaScript",
            "Lisp",
            "Perl",
            "PHP",
            "Python",
            "Ruby",
            "Scala",
            "Scheme"
        ];
        $( "#tags" ).autocomplete({
            source: availableTags,
            select: function( event, ui ) {
                console.log(ui);
                alert('select : '+ui.item.value);
                return false;
            },
            change: function(event, ui) {
                console.log(ui);
                if(!ui.item)
                        alert('change : item is null');
                else
                        alert('change : '+ui.item.value);
                return false;
            },
            close: function(event, ui) {
                console.log(ui);
                if(!ui.item)
                        alert('close : item is null');
                else
                        alert('close : '+ui.item.value);
                return false;
            },


        });
    });
    </script>
</head>

<body>

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

</body>
</html>

Thanks for your work..

Change History (10)

comment:1 Changed 7 years ago by Scott González

Resolution: notabug
Status: newclosed

The close event never has ui.item and the change event only has ui.item if an item was chosen. Please ask for help on the forums.

comment:2 Changed 7 years ago by domcars0

OK sorry for the close event. But for the change event, even if I well choose an item from the list, I have the alert('change : item is null'); This code work well with the 1.8.24 jquery-ui.

comment:3 Changed 7 years ago by tj.vantoll

@domcars0 Can you create move your example over to a jsFiddle so we can that it exists on the latest version of jQuery UI. To get started, you can use this boilerplate: http://jsfiddle.net/ZgAqH/ Open the link and click to "Fork" (in the top menu) to get started.

comment:4 in reply to:  3 Changed 7 years ago by domcars0

Replying to tj.vantoll:

@domcars0 Can you create move your example over to a jsFiddle so we can that it exists on the latest version of jQuery UI. To get started, you can use this boilerplate: http://jsfiddle.net/ZgAqH/ Open the link and click to "Fork" (in the top menu) to get started.

Hi tj.vantoll, Thanks for your answer... it's done...code is written in http://jsfiddle.net/ZgAqH/ Do you think it is normal to have the "alert('change :item is null')" when we choose 'Javascript', or 'Python' in the autocomplete list ? Sorry for my frenglish :-(

comment:5 Changed 7 years ago by domcars0

Oups sorry I think that the link is now http://jsfiddle.net/yJRnx/

comment:6 Changed 7 years ago by domcars0

Sorry again :-( hope this is the final and the good one (first time I use jsfiddle) http://jsfiddle.net/yJRnx/1/

Last edited 7 years ago by domcars0 (previous) (diff)

comment:7 in reply to:  6 ; Changed 7 years ago by tj.vantoll

Replying to domcars0:

Sorry again :-( hope this is the final and the good one (first time I use jsfiddle) http://jsfiddle.net/yJRnx/1/

I don't see the problem you're describing - http://jsfiddle.net/tj_vantoll/LS8GF/. When I select "JavaScript" or "Python" I see the value alerting as expected. What browser are you using?

comment:8 in reply to:  7 Changed 7 years ago by domcars0

Replying to tj.vantoll:

Replying to domcars0:

Sorry again :-( hope this is the final and the good one (first time I use jsfiddle) http://jsfiddle.net/yJRnx/1/

I don't see the problem you're describing - http://jsfiddle.net/tj_vantoll/LS8GF/. When I select "JavaScript" or "Python" I see the value alerting as expected. What browser are you using?

Hi. I use Firefox (on linux and on windowsXP it's the same). Yes, your code is well working, but you have remove the select event function. If you add a select event the bug come again :o( In the previous release of jquery-ui this worked with functions for the 2 events (select and change)

According to my code ,when selecting "Javascript" for exemple you would see 2 alertes messages:

  • change : Javascript
  • select : Javascript

But we (at least me with firefox) see

  • change : item is null
  • select : Javascript

Seems that ui parameter is not passed to the change event. Thank for your help.

comment:9 Changed 7 years ago by Scott González

If you return false inside select, then you're not selecting an item. This is clearly working, as proven by fiddles and unit tests. Please use the forums or StackOverflow if you still need help.

comment:10 in reply to:  9 Changed 7 years ago by domcars0

Replying to scott.gonzalez:

If you return false inside select, then you're not selecting an item. This is clearly working, as proven by fiddles and unit tests. Please use the forums or StackOverflow if you still need help.


Ok thank you I will try to found another solution :o(
Just for your information.
It works well with Opera and Epiphany-Web but not in firefox even when I return true in the select event function
I've deactivated all my Firefox (v17.0) plugins.

It seems that when an item is selected:
a) the change event function is call but without ui parameter << Cause of all my troubles
b) then the select event function is call (with good parameters)
c) and , when the focus leave the <input id='tags' />, then the change event function is call with the correct ui parameter.
Anyway thank you very much again and sorry.
Best regards

Last edited 7 years ago by domcars0 (previous) (diff)
Note: See TracTickets for help on using tickets.