mkhairi / materialize-sass

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

Dropdown isn't working in Rails #48

Closed TomSchillemans closed 9 years ago

TomSchillemans commented 9 years ago

I have the same problem with the dropdown menu and buttons.

screen shot 2015-07-12 at 2 59 13 pm

as you can see here, the dropdown-content is underneath the button and when I click on the button, I see a transparent dropdown menu and the list as it here disappears but like I said, no background color and nu highlight color.

When I tried the materialize-css example in codepen it just works!

Here's my coped example

I converted it to HAML which I use like so:

%a{ :class => 'dropdown-button btn', :href => '#', :data => {:activates => 'dropdown1'} } Drop Me!

%ul{id: 'dropdown1', class: 'dropdown-dontent'}
  %li
    %a{href: '#!'} one
  %li
    %a{href: '#!'} two
  %li.divider
  %li
    %a{href: '#!'} three
mkhairi commented 9 years ago

hi @TomSchillemans, if you using turbolink you should reinitialize dropdown js on each page load

$(document).on 'ready page:change', ->
        $('.dropdown-button').dropdown()

alternatively, you can use the jquery.turbolink gem

TomSchillemans commented 9 years ago

Thanks for the update!

I am going to try that and post back to you!

EDIT

@mkhairi I've tried both but, no luck on either method!!

mkhairi commented 9 years ago

seem like there is typo here

%ul{id: 'dropdown1', class: 'dropdown-content'}
TomSchillemans commented 9 years ago

Oh wow, yeah dang, haven't even seen that. But will that break the JS as well as the CSS of the dropdown?

mkhairi commented 9 years ago

yeah!

TomSchillemans commented 9 years ago

Ok, yeah that did the trick, I think together with the gem i installed.

Thanks for your help! Sorry I didn't see my own typo there! Thanks for pointing out. I am prone to over looking typo's. I should look out for them more often.