Search code examples
ruby-on-railstwitter-bootstrapruby-on-rails-3.2turbolinks

turbolinks issues with bootstrap modal


I doing a modal like this:

Link that shows the modal:

<%= link_to "versão resumida", resumed_rep_life_animal_path(animal, :partial => true), 'data-toggle' => 'modal', 'data-target' => '#myModal', 'data-no-turbolink' => true %>

Modal html itself:

<div class="modal hide fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-body"></div>
  <div class="modal-footer">
    <button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Fechar</button>
  </div>
</div>

But, the data-no-turbolink dont work as expected. If I refresh the page, it works ok, but, when I browse the pages with turbolinks, looks like the data-no-turbolink is just ignored.

Am I doing something wrong? I have some modals like the example in my app, don't want to remove them and dont want to remove turbolinks neither...

Thanks in advance.


Solution

  • data-no-turbolinks is not the issue here...

    It appears bootstrap js out of the box monitors only document.ready, and bootstrap JS may need modified to check for page:load as well

    Look at line 222

    This will only fire on the first request in which bootstrap is included. It needs modified to fire on page:load as well.

    One suggestion I can make is to use gem 'twitter-bootstrap-turbo' for getting bootstrap. This is a fork of twitter-bootstrap-rails , with the addition of turbolinks handlers.