Closed tricknotes closed 5 years ago
I avoid this issue using materialize via yarn.
$ yarn add materialize-css@next
# config/initializers/assets.rb
Rails.application.config.assets.paths << Rails.root.join('node_modules')
and the following changes:
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 4c2840f..b883b74 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -1,3 +1,3 @@
-//= require materialize-sprockets
+//= require materialize-css/dist/js/materialize
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index b04947c..6b2bca1 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -1,8 +1,8 @@
-@import 'materialize';
+@import 'materialize-css/sass/materialize';
I can confirm that newer versions of materialize-sass aren't working correctly. The events are created during the first page visit but are lost when navigating away and coming back (I've checked and turbolinks picks it up fine, fires the initialization scripts but modals etc. are not working).
application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require materialize-sprockets
//= require_tree .
init.coffee
window.App ||= {}
App.init = ->
$('.button-collapse').sideNav()
$('.dropdown-button').dropdown()
$('.collapsible').collapsible()
$('.tooltipped').tooltip({ delay: 50 })
$('.modal').modal()
$('select').material_select()
$(document).on('turbolinks:load', ->
App.init()
)
Last working version of materialize sass is 0.97.8
one thing you can do is reset the count before initializing it.
The event handlers for initialization are replaced by 91b3f601e1afffbd5c7761812154a276fcd96373 due to turbolinks friendly. However Materialize 1.0.0 doesn't recognize this event format. In previous Materialize version,
$
was jQuery object but now it iscach
object.This change has landed on 1.0.0-alpha.1.