AutoComplete Materialize.css does not work 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 is:

 <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' } }); } 
+5
source share
5 answers
  $(document).ready(function () {$('input.autocomplete').autocomplete({ data: { "Apple": null, "Microsoft": null, "Google": null }});}); 
+5
source

I had a similar problem with the reaction. If I execute the code inside jquery, it works.

 $(() => { $(...).autocomplete(); }); 
+1
source

Make sure you download the latest materialize.js file. I had an older version in which the autocomplete plugin was not in JS, and it threw the same error. Left after I updated. However, I still cannot get autocomplete to work. :(

0
source

my workaround:

copy function:

 /************************** * Auto complete plugin * *************************/ $.fn.autocomplete = function (options) { // Defaults var defaults = { data: {} }; options = $.extend(default (...) }); // End of $(document).ready (1) /******************* * Select Plugin * ******************/ 

from materialize.js (line number ~ 3000) or from the source file /js/forms.js( line number ~ 281)

delete the last line:

 }); // End of $(document).ready (1) 

the close function started even earlier ...

and enter it manually in javascript function body

 $(document).ready(function() { //paste it here }) 
0
source

My problem was resolved by downgrading my jQuery version to version V2.1.4, as it uses CSS CSS.

0
source

All Articles