jquery autocomplete this.source is not a function error

后端 未结 7 1334
心在旅途
心在旅途 2020-12-11 00:04

I\'ve implemented autocomplete on an input field, but the box does not show up and firebug returns \"this.source is not a function\". I\'ve used autocomplete on other fields

相关标签:
7条回答
  • 2020-12-11 00:42

    Answer is that the first parameter of the autocomplete should be an object containing the "source" property. This works

    var fakedata = ['test1','test2','test3','test4','ietsanders'];
    $("#omschrijving").autocomplete({source:fakedata});
    
    0 讨论(0)
  • 2020-12-11 00:43

    If you use it with jQuery UI library it also has plugin named autocomplete. In this case you can use plugin alias devbridgeAutocomplete:

    $('.autocomplete').devbridgeAutocomplete({ ... });
    

    This solve the problem with jQuery UI collision

    0 讨论(0)
  • 2020-12-11 00:52

    As Shelton stated, the version from devbridge.com (1.1.3) collides with jQuery UI (1.8.4). Got it working by making sure the devbridge version loads after jQuery UI's version.

    0 讨论(0)
  • 2020-12-11 00:55

    If you were trying to use autocomplete from http://www.devbridge.com/projects/autocomplete/jquery/#demo, it now collides with the autocomplete method in jQuery UI. I had the same problem and later noticed that I could just use the jQuery UI implementation.

    (NOTE: It appears that this page's documentation is wrong: http://docs.jquery.com/Plugins/Autocomplete#Setup)

    0 讨论(0)
  • 2020-12-11 01:01

    in my case I had a second import of jquery which I didn't realize. Something like:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.devbridge-autocomplete/1.2.27/jquery.autocomplete.min.js"></script> 
    
    // More code
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"> </script>
    

    So be sure to import the autocomplete script after you initialized jquery.

    0 讨论(0)
  • 2020-12-11 01:03

    Had similar problem for tagedit/autocomplete. It seems you also want to disable the autocomplete. Setting the source to false avoids these errors.

    Solution:

    options.autocompleteOptions.source = false;
    
    0 讨论(0)
提交回复
热议问题