anjlab / bootstrap-rails

Twitter Bootstrap CSS (with Sass flavour) and JS toolkits for Rails 3 projects
https://github.com/anjlab/bootstrap-rails
729 stars 96 forks source link

dropdown and turbolinks doesn't work together #70

Closed naaano closed 11 years ago

naaano commented 11 years ago

you have to add "data-no-turbolink" to the dropdowns to get them working.

%ul.dropdown-menu{:role => 'menu', :'aria-labeledby' => "something", "data-no-turbolink" => true}

This is not a turbolink nor bootstrap issue, but the mix of both. That's why i add this here. Just to help those pulling their hair off.

amejiarosario commented 10 years ago

Thank you!!!!

caiogouveia commented 10 years ago

Thank you !!

sheharyarn commented 9 years ago

The problem with this approach is that if you arrive on the page via a turbolink page:change event, the dropdown won't still work.

I was able to fix this issue by adding data-turbolinks-eval=false to the to the application.js <script> tag. By doing this, the application.js javascript isn't re-evaluated every time there is a page:change event, so it doesn't break the dropdown js.

My application.html.slim:

/ JS at the End
== javascript_include_tag 'application', 'data-turbolinks-eval': false
== javascript_include_tag params[:controller]
== yield(:page_javascript) if content_for?(:page_javascript)

Thanks to @reed on https://github.com/rails/turbolinks/issues/539