Skip to content

Commit

Permalink
Remove turbolinks globally
Browse files Browse the repository at this point in the history
Some application javascript (e.g., Ace Editor) did not load initially
and a page reload was necessary every time.
It seems that the migration to `turbolinks:load` with Turbolinks version >=5
caused several issues on loading javascript and firing events:
* Turbolinks 5 discussion: kossnocorp/jquery.turbolinks#56
* Fixes bindings on `ready` event: https://github.com/wshostak/turbolinks-jquery
* Compatibility script: https://github.com/turbolinks/turbolinks/blob/master/src/turbolinks/compatibility.coffee

Removes the `page:load` listeners by replacing:
`$(document).on('ready page:load', function () {` with
`$(document).ready(function () {`

Removing all turbolinks related code fixed this issue.
  • Loading branch information
joe4dev committed Jul 9, 2017
1 parent fa76c54 commit 444debf
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 32 deletions.
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ gem 'less-rails', '~> 2.8'
gem 'uglifier', '~> 3.2'
gem 'jquery-rails'
gem 'coffee-rails', '~> 4.2', '>= 4.2.2'
gem 'turbolinks'
gem 'jquery-turbolinks'
gem 'jbuilder', '~> 2.7'

## UI
Expand Down
8 changes: 0 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-turbolinks (2.1.0)
railties (>= 3.1.0)
turbolinks
json (2.1.0)
kgio (2.11.0)
launchy (2.4.3)
Expand Down Expand Up @@ -301,9 +298,6 @@ GEM
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.7)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.3)
tzinfo (1.2.3)
thread_safe (~> 0.1)
uglifier (3.2.0)
Expand Down Expand Up @@ -346,7 +340,6 @@ DEPENDENCIES
guard-rspec
jbuilder (~> 2.7)
jquery-rails
jquery-turbolinks
launchy
less-rails (~> 2.8)
meta_request
Expand All @@ -368,7 +361,6 @@ DEPENDENCIES
sqlite3
therubyracer (~> 0.12.3)
thin
turbolinks
uglifier (~> 3.2)
unicorn
whenever (~> 0.9.7)
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/ace_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var configure_ace = function() {
}
};

$(document).on('ready page:load', function () {
$(document).ready(function () {
configure_ace();
$('#ace_expand').click(function() {
resize_ace_editor();
Expand Down
6 changes: 0 additions & 6 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

//= require jquery
//= require jquery_ujs
//= require jquery.turbolinks
//= require bootstrap/bootstrap
//= require bootstrap-slider/bootstrap-slider

Expand Down Expand Up @@ -43,8 +42,3 @@
//= require tooltips
//= require sign_in
//= require slider



// Require as last resource according to jquery turbolinks docs: https://github.com/kossnocorp/jquery.turbolinks
//= require turbolinks
9 changes: 1 addition & 8 deletions app/assets/javascripts/live_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,7 @@ function resetLiveRefreshButton(id) {
stop.hide();
}

$(document).on('ready page:load', function () {
$(document).ready(function () {
initLiveRefresh('prepareLog', 'prepare_log');
initLiveRefresh('releaseResourcesLog', 'release_resources_log');
});

// Reset timeout when leaving the page via Rails turbolinks.
$(document).on('page:before-change', function() {
resetLiveRefreshButton('prepareLog');
resetLiveRefreshButton('releaseResourcesLog');
resetAllLogRefreshTimeouts();
});
2 changes: 1 addition & 1 deletion app/assets/javascripts/sign_in.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jQuery.fn.center_sign_in = function() {
return this;
}

$(document).on('ready page:load', function () {
$(document).ready(function () {
startTime();
$(".center").center_sign_in();
$(window).resize(function() {
Expand Down
5 changes: 1 addition & 4 deletions app/assets/javascripts/tooltips.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
// The on page:load hook is required in order to support Rails turbolinks.
// For more information see: https://github.com/rails/turbolinks#events
// RailsCast with example and background: http://railscasts.com/episodes/390-turbolinks
$(document).on('ready page:load', function () {
$(document).ready(function () {
// Tooltips
$(function () { $('.tooltip-show').tooltip('show');});
$(function () { $('.tooltip-hide').tooltip('hide');});
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/_head.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<title><%= content_for?(:title) ? yield(:title) : "Cloud WorkBench" %></title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>

<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
Expand Down

0 comments on commit 444debf

Please sign in to comment.