Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery autocomplete renderItem

I have the following code. It generates no js errors. Can't get the autocomplete to display any results:

$(function() {
    $.ajax({
    url: "data.xml",
    dataType: "xml",
    cache: false,
    success: function (xmlResponse) {
        var data_results = $("Entry", xmlResponse).map(function () {
            return {
                var1: $.trim($("Partno", this).text()),
                var2: $.trim($("Description", this).text()),
                var3: $.trim($("SapCode", this).text()),
                var4: $("Title", this).text(),
                var5: $.trim($("File", this).text()),
                var6: $.trim($("ItemID", this).text())
            };
        }).get();

        $("#searchresults").autocomplete({
            source: data_results,
            minLength: 3,
            select: function (event, ui) {
                ...
            }
        }).data( "autocomplete" )._renderItem = function( ul, item ) {
                return $( "<li></li>" ).data("item.autocomplete", item)
                    .append( "<a>" + item.var1 + "<br>" + item.var2 + "</a>")
                    .appendTo( ul );
        };

    }
});

Any ideas what I might be missing? Thanks in advance.

like image 347
Esteban Avatar asked Mar 27 '13 17:03

Esteban


1 Answers

It seems that .data('autocomplete') is now .data('ui-autocomplete').

Source: http://jqueryui.com/upgrade-guide/1.10/#removed-data-fallbacks-for-widget-names

like image 97
Dzulqarnain Nasir Avatar answered Sep 21 '22 04:09

Dzulqarnain Nasir