Jquery autocomplete custom data error no such method 'instance' for autocomplete widget instance
Asked Answered
X

1

24

I am adding the autocomplete functionality to text box. Referring this jQuery autocomplete custom data plugin.

Without custom data code it is working fine. I have added following custom data code

 .autocomplete( "instance" )._renderItem = function( ul, item ) {
                        return $( "<li>" )
                          .append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
                          .appendTo( ul );
                      };

it throws error as

no such method 'instance' for autocomplete widget instance

is there anything that I am missing.

I am using jQuery v1.11.2 and jQuery UI - v1.10.3

Xenophobia answered 21/5, 2015 at 6:0 Comment(0)
X
33

Updated the syntax for the new version: I think they are not using instance now.

       $("#Id").autocomplete().data("uiAutocomplete")._renderItem =  function( ul, item ) 
       {
         return $( "<li>" )
         .append( "<a>" + item.label + "<br>" + item.desc + "</a>" )
         .appendTo( ul );
       };
Xenophobia answered 21/5, 2015 at 8:50 Comment(4)
it was .data("ui-autocomplete") for meChainman
It was catcomplete for me. To see what it might be for you, console.log($("#Id").autocomplete().data())Kentkenta
Why are items not selectable? I've implemented your solution and works fine for subitems. Problem is, I can not select those items.Cleon
@Cleon check console for possible JS errors. I had to recreate whole <li> (with proper css classes) to get it to work.Vaporetto

© 2022 - 2024 — McMap. All rights reserved.