turbolinks issues with bootstrap modal

大兔子大兔子 提交于 2019-11-29 01:56:52
davydotcom

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.

As davydotcom said, the reason the modals aren't working is because they are bound to $(document).ready instead of $(document).on('page:change'), which is what turbolinks uses.

The jquery-turbolinks gem will make it so that ready calls will also respond to turbolink's page:change calls.

Step 1: Add gem jquery-turbolinks to your Gemfile.

Step 2: Add it to your JavaScript manifest file, in this order:

//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//
// ... your other scripts here ...
//
//= require turbolinks

Step 3: Restart your server. Boom!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!