Skip to main content

Search and Top Navigation

#8847 closed bug (notabug)

Opened November 23, 2012 09:58AM UTC

Closed November 23, 2012 12:23PM UTC

Last modified November 25, 2012 10:32AM UTC

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..

Attachments (0)
Change History (10)

Changed November 23, 2012 12:23PM UTC by scottgonzalez comment:1

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.

Changed November 23, 2012 02:07PM UTC by domcars0 comment:2

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.

Changed November 23, 2012 06:46PM UTC by tj.vantoll comment:3

@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.

Changed November 23, 2012 10:32PM UTC by domcars0 comment:4

Replying to [comment:3 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 :-(

Changed November 23, 2012 10:33PM UTC by domcars0 comment:5

Oups sorry I think that the link is now

http://jsfiddle.net/yJRnx/

Changed November 23, 2012 10:36PM UTC by domcars0 comment:6

_comment0: Sorry again :-( \ hope this is the finaland the good one (first time I use jsfiddle) \ http://jsfiddle.net/yJRnx/1/1353793750406302

Sorry again :-(

hope this is the final and the good one (first time I use jsfiddle)

http://jsfiddle.net/yJRnx/1/

Changed November 24, 2012 10:48PM UTC by tj.vantoll comment:7

Replying to [comment:6 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?

Changed November 25, 2012 01:44AM UTC by domcars0 comment:8

Replying to [comment:7 tj.vantoll]:

Replying to [comment:6 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.

Changed November 25, 2012 01:56AM UTC by scottgonzalez comment:9

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.

Changed November 25, 2012 10:32AM UTC by domcars0 comment:10

_comment0: Replying to [comment:9 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 cursor leave the <input id='tags' />, then the change event function is call with the ui parameter. \ \ Anyway thank you very much again and sorry. \ Best regards1353965003267845

Replying to [comment:9 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