Skip to content

Commit a0694d5

Browse files
committed
Add PJAX fallback
1 parent ec180fc commit a0694d5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sophora-components/datawrapper-switcher.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,22 @@
5050
});
5151
console.log('Module loaded, mounting Datawrapper Switcher immediately');
5252
window.__mountDatawrapperSwitcher();
53+
54+
if (window.$) {
55+
$(document).on('pjax:end', () => {
56+
console.log('PJAX navigation detected (jQuery), remounting Datawrapper Switcher');
57+
window.__mountDatawrapperSwitcher();
58+
});
59+
} else {
60+
console.warn(
61+
'jQuery not found, PJAX support for Datawrapper Switcher will be unavailable'
62+
);
63+
}
5364
}
5465
</script>
66+
<script>
67+
console.log('Executing inline script to mount Datawrapper Switcher');
68+
window.__mountDatawrapperSwitcher && window.__mountDatawrapperSwitcher();
69+
</script>
5570
</body>
5671
</html>

0 commit comments

Comments
 (0)