Skip to content

Using with Turbolinks

russellbrown edited this page Jan 28, 2016 · 1 revision

Turbolinks uses ajax to fetch the requested page and only replaces the <body> and <title> tags.

This creates a problem when using Slideout.js because when you open a menu Slideout.js adds the class .slideout-open to the <html> tag which is not touched by Turbolinks. The result is that the class is still present on the newly loaded page and prevents scrolling from working.

The solution is to use the Turbolinks page:load event to remove the class:

$(document).on("page:load", function(){  
  $("html").removeClass("slideout-open");
});
Clone this wiki locally