Jquery autocomplete: this.menu undefined

I am using jQuery UI autocomplete for some data. Now I have 3 autocomplete items, and 2 of them work fine, and one doesn't. At the top of the page, it gives an error elem.ownerDocument is null. When I put the text in the field input, it finds the result, but I get an error this.menu is undefined (jquery.js line 6012)that refers to ul listwhere the result should be shown.

Here is the code:

$("#iName").autocomplete({
    source: widget.festivals_list,
    autofocus: true,
    focus: function (e, ui) {
        return false;
    },
    search: function (event, ui){
        ownFest = true;
        $("#iDate").removeAttr("disabled");
        $("#iTime").removeAttr("disabled");
    },
    select: function (event, ui) {
        ownFest = false;
        $(event.target).val(ui.item.label);
        selectedN = ui.item.value;
        $(widget.festivals).each(function fn(){
            if(this.id == ui.item.value){
                $("#iDate").val(this.date).attr("disabled", "disabled");
                $("#iTime").val(this.time).attr("disabled", "disabled");
            }
        });
        return false;
    }
});

HTML CODE:

<table>
                    <tr>
                        <td>Type the name</td>
                    </tr>
                    <tr>
                        <td><input type="text" id="iFest"/></td>
                    </tr>
                </table>

This creates a typical number of attributes in my tag inputand creates a list ul.

<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all" role="listbox" aria-activedescendant="ui-active-menuitem"></ul>

<input id="iFest" class="ui-autocomplete-input" type="text" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">

Anyone who also had these problems? Thanks

(Using jQuery 1.5.2 and jQuery UI 1.8.11)

thank

+3
source share
2 answers

I believe because your 'this' is beyond the scope.

'this' , .

- 'this'

var element = $(this);

var me = this;

'this', .

HTML- ? , ? , .

0

, .

, :

<script type="text/javascript" src="js/ui/jquery.ui.menu.js"></script>

!

0

All Articles