File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ $.fn.scrollTo = function(selector) {
2020 } , ANIMATION_DURATION ) ;
2121} ;
2222
23- $ ( document ) . on ( 'turbo-migration:load' , function ( ) {
23+ $ ( document ) . on ( 'turbo-migration:load' , function ( event ) {
2424 // Update all CSRF tokens on the page to reduce InvalidAuthenticityToken errors
2525 // See https://github.com/rails/jquery-ujs/issues/456 for details
2626 $ . rails . refreshCSRFTokens ( ) ;
@@ -63,7 +63,9 @@ $(document).on('turbo-migration:load', function() {
6363 }
6464
6565 // Enable sorttable again, as it is disabled otherwise by Turbo
66- if ( sorttable ) {
66+ // We use the event details to determine whether an ordinary page load occurred or a Turbo visit
67+ // In some events (i.e., for a failed form submission), `event.detail.timing` is not set (despite a Turbo "visit").
68+ if ( sorttable && ( event . detail ?. timing ? Object . keys ( event . detail . timing ) . length > 0 : true ) ) {
6769 sorttable . init . done = false ;
6870 sorttable . init ( ) ;
6971 }
You can’t perform that action at this time.
0 commit comments