-
Notifications
You must be signed in to change notification settings - Fork 65
Initial support fo turbolinks 5 #58
base: master
Are you sure you want to change the base?
Conversation
Please see #56 (comment) TL;DR: I'm looking for a new project owner. |
"jquery": "~2.1.1", | ||
"jsdom": "~1.0.0-pre.4" | ||
"jquery": "~2.2.2", | ||
"jsdom": "~8.1.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time flies!
@dalpo please upgrade version to It should help with Travis CI. |
Just tested this and it appears that Here is a JSFiddle of the issue. I noticed if I comment out |
The handler is called twice because Turbolinks 5, unlike the Classic one, calls However, there is a bigger elephant in this room: Turbolinks 5 caches the body by cloning it, which means none of the bound event handlers are preserved (unlike Turbolinks classic). This means all of the DOM transformations on load need to be either idempotent, or the transformation should be reverted before caching (this effectively means the user must call old-school plugin destructors on jQuery.Turbolinks could be rewritten to do something like this: jQuery(function() {
if (!('Turbolinks' in window || !window.Turbolinks.supported)) {
triggerOnPageLoad();
} else {
// jquery.turbolinks must be required before Turbolinks, so that
// the `turbolinks:load` event will not have triggered yet.
document.addEventListener('turbolinks:load', () => {
triggerOnPageLoad();
});
}
}); However, because of the aforementioned changes in the Turbolinks 5 caching mechanism, jquery.turbolinks can no longer just "make" the old stuff work unless the user disables Turbolinks 5 Caching entirely. We would need to instruct the users to make the DOM modifications idempotent or remind them to revert these on $(() => { $('select').select2() }
document.addEventListener('turbolinks:before-cache', () => {
$('select').select2('destroy');
$('.select2-drop, .select2-drop-mask').remove();
}); |
No description provided.