From 45bd1f6ab40f11dfd5bb40965d2f5f87a2f55995 Mon Sep 17 00:00:00 2001 From: redfast00 Date: Sat, 24 Aug 2019 21:08:11 +0200 Subject: [PATCH] Fix #39 This was caused by the javascript not loading: the turbolink event for when a page is loaded has changed from 'page:load' to 'turbolinks:load'. --- Gemfile | 2 +- Gemfile.lock | 8 +++++--- app/assets/javascripts/application.js | 7 ++----- app/assets/javascripts/transactions.js | 10 +++++----- 4 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index ad8106f..d33a1c0 100644 --- a/Gemfile +++ b/Gemfile @@ -99,7 +99,7 @@ gem 'high_voltage', '~> 3.1' # Errors on errbit gem 'airbrake' -gem 'bootstrap-sass', '~> 3.3.5' +gem 'bootstrap-sass', ">= 3.4.1" gem 'react-rails', '~> 1.10.0' gem 'rolify' gem 'rails-controller-testing' diff --git a/Gemfile.lock b/Gemfile.lock index f728dd1..c6381a1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -61,9 +61,9 @@ GEM bcrypt (3.1.13) bcrypt_pbkdf (1.0.1) bindex (0.8.1) - bootstrap-sass (3.3.7) + bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) - sass (>= 3.3.4) + sassc (>= 2.0.0) builder (3.2.3) byebug (11.0.1) cancancan (3.0.1) @@ -291,6 +291,8 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) + sassc (2.1.0) + ffi (~> 1.9) sdoc (0.4.2) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) @@ -346,7 +348,7 @@ DEPENDENCIES airbrake annotate bcrypt_pbkdf - bootstrap-sass (~> 3.3.5) + bootstrap-sass (>= 3.4.1) byebug cancancan capistrano (~> 3.1) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 8362bf4..3e79194 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -26,7 +26,7 @@ //= require chartkick //= require_tree . -ready = function() { +$(document).on('turbolinks:load', function() { $.each($(".select2-selector"), function(index, val) { $(val).select2({ width: $(val).data('width'), @@ -34,7 +34,4 @@ ready = function() { allowClear: true }); }) -} - -$(document).ready(ready) -$(document).on('page:load', ready) +}); diff --git a/app/assets/javascripts/transactions.js b/app/assets/javascripts/transactions.js index a7071f6..15fb3c6 100644 --- a/app/assets/javascripts/transactions.js +++ b/app/assets/javascripts/transactions.js @@ -1,10 +1,13 @@ -ready = function() { +$(document).on('turbolinks:load', function() { form = $("#new_transaction"); submit_button = $(form).find("input[type=submit]"); errors = $("#transaction_errors"); panel_ul = $(errors).find(".panel-body ul"); flash_success = $("#transaction_success"); + if ($("#users-transactions")[0]) { + return; + } var table = $('#transactions').DataTable({ processing: true, serverSide: true, @@ -107,12 +110,9 @@ ready = function() { $(submit_button).attr('disabled', false); table.ajax.reload(); }); -} +}); $.ajaxSetup({ dataType: 'text' }); - -$(document).ready(ready); -$(document).on('page:load', ready);