question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

autocomplete is not a function

See original GitHub issue

Hi, I’m working on a rails application using materializecss gem.

markup:

<div class="row">
  <div class="col s12">
    <div class="row">
      <div class="input-field col s13">
        <i class="material-icons prefix">textsms</i>
        <input type="text" id="autocomplete" class="autocomplete">
        <label for="autocomplete">Autocomplete</label>
      </div>
    </div>
  </div>
</div>

js:

$(document).ready(function(){
  $('input.autocomplete').autocomplete({
             data: {
                 "Apple": null,
                 "Microsoft": null,
                 "Google": null
             }});
});

but got the error: TypeError: $(‘input.autocomplete’).autocomplete is not a function. (In ‘$(‘input.autocomplete’).autocomplete’, ‘$(‘input.autocomplete’).autocomplete’ is undefined)

Then, I tried to execute following snippet in browser console:

  $('input.autocomplete').autocomplete({
             data: {
                 "Apple": null,
                 "Microsoft": null,
                 "Google": null
             }});

Then, the autocomplete works. Could anybody help with this? Thank you very much.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8

github_iconTop GitHub Comments

7reactions
prashantkhuranacommented, Jun 4, 2017

Happening here also

  • with Vue
  • directly importing from cdn
  • jquery-2.1.1 then 0.98.2/css/materialize.min.css and last 0.98.2/js/materialize.min.js

I wrapped it then under $(document).ready as suggested and it works fine.

$(document).ready(function(){
  $('.chips-autocomplete').material_chip({
    autocompleteOptions: {
      data: {
        'Apple': null,
        'Microsoft': null,
        'Google': null
      },
      limit: Infinity,
      minLength: 1
    }
  });
});
5reactions
Kacxxiacommented, Jun 12, 2017

Also happening with plain html , ‘$(document).ready()’ solves the problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

jquery - .autocomplete is not a function Error - Stack Overflow
When I run the application from visual studio it worked all fine, but when I published the project and tested it , I've...
Read more >
TypeError: $(...).autocomplete is not a function in jQuery
To solve the "$(...).autocomplete is not a function" jQuery error, make sure to load the jQuery library before loading the jQuery UI library....
Read more >
TypeError autocomplete is not a function | Edureka Community
I am getting the TypeError: $(...).autocomplete is not a function when using the following code inside a Drupal module.
Read more >
Uncaught typeerror $(...).autocomplete is not a function jQuery ...
Another case of getting TypeError: $(…).autocomplete is not a function is when you miss the jQuery UI library. Use CDN of Jquery UI...
Read more >
How to solve jQuery autocomplete is not a function in ...
Here is my script, I don't know what is the problem but it show JQuery autocomplete is not a function in console.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found