-->

autocomplete showing self.element.propAttr error

2020-08-14 07:37发布

问题:

I am using Jquery ui Autocomplete.But it show error autocomplete showing self.element.propAttr error. this is my ajax code

$.ajax({
        url: "persons.xml",
        dataType: "xml",
        success: function( xmlResponse ) {
            var data = $( "person", xmlResponse ).map(function() {
                return {
                    value: $( "name", this ).text()

                };
            }).get();
            $( "#birds" ).autocomplete({
                source: data,
                minLength: 0

            });


        }

    });

I am using xml for response but that doesnot seem to be the problem it seems some function in javascript is deprecated. Can anyone give me any solutions for this?

回答1:

Add this lines in front of your statement:

jQuery.fn.extend({
 propAttr: $.fn.prop || $.fn.attr
});


回答2:

I was facing this problem when refactoring my javascript and found that the problem was I removed jquery.ui.core.js, and instead was using only jquery-ui-1.9.1.custom.min.js.

I created this file using the Download Builder at the Jquery UI website with everything checked. Correct me If I am wrong but jquery-ui-1.9.1.custom.min.js should have contained all the javascript necessary to run all the jquery ui addins (in this case autocomplete was failing).

Adding the reference back to jquery.ui.core.js fixed the bug.