Search code examples
javascriptjqueryruby-on-railsruby-on-rails-4turbolinks

Turbolinks makes page loaded blank


I think it is Turbolinks causing this issue, but if I am on my root_path while logged in and go to a bunch of different pages and come back to my root_path and the bulk of the main part of the page doesn't show.

The log shows that all the elements are loaded, when I view source I see all of the elements - but it just doesn't show up on the page on the 2nd load of the root_path.

This is my application.js

//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require bootstrap
//= require bootstrap-sprockets
//= require best_in_place
//= require jquery-ui/datepicker
//= require best_in_place.jquery-ui
//= require jquery.purr
//= require best_in_place.purr
//= require bootstrap.file-input
//= require chosen.jquery
//= require spin.min
//= require ladda.min
//= require masonry.js
//= require main.js
//= require intro.js 
//= require turbolinks

$(document).ready(function() {
  /* Activating Best In Place && Include Success Highlighting & Bounce for comments & videos */
  jQuery(".best_in_place").best_in_place().bind("ajax:success", function () {$(this).closest('p, h5').effect('highlight').effect("bounce", { times:3 },  { duration:400}).dequeue(); });
});

$(document).on("page:load ready", function(){
    $("input.datepicker").datepicker();
});

In my application.html.erb:

<%= javascript_include_tag "application", "data-turbolinks-track" => true %>

I even tried adding this to my application.js but it still doesn't work:

$(document).ready(ready);
$(document).on('page:load', ready);

Solution

  • That is masonry library. And it's still not figured out

    turbolinks with masonry is not working.

    You may use grid from any css framework or use EX http://isotope.metafizzy.co/ which works with infinite scroll too :)