Search code examples
ruby-on-railsturbolinks

Turbolinks in ruby on rails


I am using turbolinks in my project. In index action I have show link when the link is clicked the preloader loads and nothing happens. I have enabled turbo-links-track :'reload' option to track the changes in the source. Why links are not behave correctly if turbolins enabled. If I disable the turbolink by data-turbo-links:false it works fine.

At application.html.erb

 <%= javascript_include_tag 'security_managers/application', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag params[:controller], 'data-turbolinks-track': 'reload' %>

This is in index view

 <button class="btn"><%=link_to  image_tag("view.svg"), staff_path(staff), 'data-turbolinks': false %>
 <%= will_paginate @collection, previous_label:"", next_label:"", page_links: false, 'data-turbolinks': false %>

Solution

  • check the proper links in the application.html.erb, In the /application.js //= require turbolinks, Also call your functions like that : $(document).on("turbolinks:load", function()