Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Materialize.css autocomplete not working with Polymer

I am trying to use Materialize.css autocomplete with my Polymer project.

Console Log:

Uncaught TypeError: $(...).autocomplete is not a function

My Code:

<div class="input-field">
    <input type="text" id="assemp" class="autocomplete" value="{{emps::input}}">
    <label for="assemp">Assigned Employee(s)</label>
</div>

Script:

attached : function() {
            $('input.autocomplete').autocomplete({
                data: {
                    "Apple": null,
                    "Microsoft": null,
                    "Google": 'http://placehold.it/250x250'
                }
            });
        }
like image 936
Yahya Ayash Luqman Avatar asked Jul 27 '16 19:07

Yahya Ayash Luqman


3 Answers

 $(document).ready(function () {$('input.autocomplete').autocomplete({
            data: {
                "Apple": null,
                "Microsoft": null,
                "Google": null
            }});});
like image 88
Alireza Avatar answered Sep 21 '22 19:09

Alireza


Make sure you are loading the most recent materialize.js file. I had an older version where the autocomplete plugin was not in the JS and it was throwing that same error. Went away after I updated. However i still can't get the autocomplete to work. :(

like image 21
Wesley Williams Avatar answered Sep 20 '22 19:09

Wesley Williams


I ran into a similar issue with react. If I execute the code within jquery it seems to work.

$(() => {
  $(...).autocomplete();
});
like image 45
RandomCode Avatar answered Sep 21 '22 19:09

RandomCode