11

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?

2 Answers 2

25

Add this lines in front of your statement:

jQuery.fn.extend({
 propAttr: $.fn.prop || $.fn.attr
});
3
  • I have solved this problem.thanks for the answer. web console was pointing towards self.options.disabled|| self.element.propAttr("readOnly") as error.this line in jquery.ui.autocomplete.js .I deleted that line altogether and voila!! it worked.May be that is not good practice but it worked.i will try your suggestion though.. May 14, 2012 at 9:41
  • 1
    @Narendra Chitrakar : Could you explain why/how this solves the problem and what the problem was in the first place?
    – Shawn
    Oct 25, 2012 at 20:27
  • Deleting the line will make it show for readonly or disabled inputs as well as inputs for which you can actually select a value, given answer does the trick, is their extra value to the extend? surely it could be jQuery.fn.propAttr = $.fn.prop || $.fn.attr;
    – PJUK
    Jun 16, 2014 at 14:53
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.