mkhairi / materialize-sass

Materializecss rubygem for Rails Asset Pipeline / Sprockets
http://materialize.labs.my/
MIT License
805 stars 243 forks source link

Uncaught TypeError: Materialize.updateTextFields is not a function #142

Closed dbarison closed 7 years ago

dbarison commented 7 years ago

https://github.com/Dogfalo/materialize/issues/3914

emoon3 commented 7 years ago

To get this working I had to turn off turbolinks. It still didn't work until I changed my application.js file.

I had to change: //= require materialize-sprockets

to

//= require materialize

eiwi1101 commented 7 years ago

This is related to Materialize.updateTextFields not being defined until turbolinks:load is fired. I've adjusted forms.js in a fork to define this outside that scope, though I'm not 100% sure that's the correct solution.

https://github.com/sitehive/materialize-sass/blob/master/app/assets/javascripts/materialize/forms.js

I've also added Materialize.initializeForms for use manually in dynamic generated content, and am calling that on Turbolinks load.

Disabling Turbolinks and changing to //= require materialize above will pull in the original minified library and fix most of these (though Forms still can't be dynamically initialized.)

benaubin commented 7 years ago

Proposed a PR that should fix this:

https://github.com/mkhairi/materialize-sass/pull/145

juliosilvacwb commented 6 years ago

put a ngClass in your label like this

<label for="name" [ngClass]="{'active': user.name }">Name