Skip to content

Commit

Permalink
Consider new Turbolinks 5 event names
Browse files Browse the repository at this point in the history
Turbolinks 5 has renamed their events, so we should rely on the
`turbolinks:load` to make sweet alerts work.

I'm adding this event but not removing `page:load` and `page:update`
in order to support the classic version of Turbolinks
(https://github.com/turbolinks/turbolinks-classic)

In this way, rails apps using either version of TL are covered.
  • Loading branch information
jmbejar committed Apr 20, 2016
1 parent 60aa412 commit 2c08219
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/assets/javascripts/sweet-alert-confirm.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ var sweetAlertConfirmConfig = sweetAlertConfirmConfig || {}; // Add default conf

return false;
}
$(document).on('ready page:update ajaxComplete', function() {
$(document).on('ready turbolinks:load page:update ajaxComplete', function() {
$('[data-sweet-alert-confirm]').on('click', sweetAlertConfirm)
});

$(document).on('ready page:load', function() {
$(document).on('ready turbolinks:load page:load', function() {
//To avoid "Uncaught TypeError: Cannot read property 'querySelector' of null" on turbolinks
if (typeof window.sweetAlertInitialize === 'function') {
window.sweetAlertInitialize();
Expand Down

0 comments on commit 2c08219

Please sign in to comment.