Skip to content

Commit e314717

Browse files
committed
Improved documentation
1 parent 5d0aecf commit e314717

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

webroot/js/toolbar.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,20 @@ if (elem) {
9292
};
9393
};
9494

95-
// Bind on ready callback.
95+
// Bind on ready callbacks to DOMContentLoaded (native js) and turbolinks:load
96+
// Turbolinks replaces the body and merges the head of an HTML page.
97+
// Since the body is already loaded (DOMContentLoaded), the event is not triggered.
9698
if (doc.addEventListener) {
99+
// This ensures that all event listeners get applied only once.
97100
if (!window.__debugKitListenersApplied) {
101+
// The DOMContentLoaded is for all pages that do not have Turbolinks
98102
doc.addEventListener('DOMContentLoaded', onReady, false);
99103
doc.addEventListener('DOMContentLoaded', proxyAjaxOpen, false);
100104
doc.addEventListener('DOMContentLoaded', proxyAjaxSend, false);
101105

106+
// turbolinks:load is the alternative DOMContentLoaded Event of Turbolinks
107+
// https://github.com/turbolinks/turbolinks
108+
// https://github.com/cakephp/debug_kit/pull/664
102109
doc.addEventListener('turbolinks:load', onReady, false);
103110
doc.addEventListener('turbolinks:load', proxyAjaxOpen, false);
104111
doc.addEventListener('turbolinks:load', proxyAjaxSend, false);

0 commit comments

Comments
 (0)