PROBLEM
Javascript of my web application built in Ruby-2.3.3
, Rails 4.2.7.1
stopped working when I reset filters of Filterrific 2.1.2
or change page, with pagination provided by Will_paginate 3.1.5
and Will_paginate-bootstrap 1.0.1
.
I notice that when Turbolinks 5.0.1
is disabled, the problem was gone.
JAVASCRIPT EXAMPLE
bootstrap-datepicker-rails 1.6.4.1
stop working after filters are reset. Also any code included in file application.js
.
$(function() {
$('.input-daterange').datepicker({
format: "yyyy-mm-dd",
language: "pt-BR",
autoclose: true
});
});
QUESTION
Anyone has a solution that's not involve disable Turbolinks? I also tried the gem jquery-turbolinks
and get no results.
Looks like you initilize your frontend logic in $(document).ready
, but when using Turbolinks you have to do it in $(document).on('turbolinks:load')
.
For deeper knowledge take a look at Building your turbolinks application section of official documentation