From e6993c2af2294a46431fdf18fdb16dc48988556d Mon Sep 17 00:00:00 2001 From: Mikhail Titov Date: Thu, 29 Dec 2016 18:02:45 -0600 Subject: [PATCH] This closes #48 --- Gemfile | 1 + app/assets/javascripts/tabulatr/_events.js | 8 ++++---- spec/dummy/app/assets/javascripts/application.js | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 9cead1a..91c1dfe 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source 'https://rubygems.org' gemspec gem 'jquery-rails' +gem 'turbolinks' gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw] group :development, :test do diff --git a/app/assets/javascripts/tabulatr/_events.js b/app/assets/javascripts/tabulatr/_events.js index 30497b5..46c7456 100644 --- a/app/assets/javascripts/tabulatr/_events.js +++ b/app/assets/javascripts/tabulatr/_events.js @@ -1,7 +1,4 @@ -$(function(){ - tabulatr_tables = []; - - $('th.tabulatr-sortable').click(function(){ + $(document).on('click', 'th.tabulatr-sortable', function(){ var th = $(this); var sort_by = th.data('tabulatr-column-name'); var dir = th.attr('data-sorted'); @@ -30,6 +27,8 @@ $(function(){ table_obj.updateTable({}); }); +$(document).on('ready page:load turbolinks:load', function(){ + tabulatr_tables = []; $('.tabulatr_table').each(function(ix, el){ if($('.pagination[data-table="'+ $(el).attr('id') +'"]').length === 0){ @@ -223,6 +222,7 @@ $(function(){ $(document).on('click', 'a[data-show-filters-for]', function(){ var a = $(this); a.parents('.tabulatr-outer-wrapper').addClass('filtered'); + return false; }); }); diff --git a/spec/dummy/app/assets/javascripts/application.js b/spec/dummy/app/assets/javascripts/application.js index bc651e3..04fe57d 100644 --- a/spec/dummy/app/assets/javascripts/application.js +++ b/spec/dummy/app/assets/javascripts/application.js @@ -13,4 +13,5 @@ //= require jquery_ujs //= require bootstrap //= require tabulatr +//= require turbolinks //= require_tree .