Skip to content

Commit

Permalink
Fix: bind pjax event on document instead of window
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Apr 25, 2020
1 parent cd5e541 commit 75695df
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion layout/_scripts/pages/schedule.njk
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

fetchData();
var fetchDataTimer = setInterval(fetchData, 60000);
window.addEventListener('pjax:send', () => {
document.addEventListener('pjax:send', () => {
clearInterval(fetchDataTimer);
});

Expand Down
2 changes: 1 addition & 1 deletion layout/_scripts/pjax.njk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var pjax = new Pjax({
scrollTo : !CONFIG.bookmark.enable
});
window.addEventListener('pjax:success', () => {
document.addEventListener('pjax:success', () => {
document.querySelectorAll('script[data-pjax], script#page-configurations, #pjax script').forEach(element => {
var code = element.text || element.textContent || element.innerHTML || '';
var parent = element.parentNode;
Expand Down
2 changes: 1 addition & 1 deletion source/js/algolia-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
});
document.querySelector('.popup-btn-close').addEventListener('click', onPopupClose);
window.addEventListener('pjax:success', onPopupClose);
document.addEventListener('pjax:success', onPopupClose);
window.addEventListener('keyup', event => {
if (event.key === 'Escape') {
onPopupClose();
Expand Down
4 changes: 2 additions & 2 deletions source/js/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ document.addEventListener('DOMContentLoaded', () => {
if (trigger === 'auto') {
// Register beforeunload event
window.addEventListener('beforeunload', doSaveScroll);
window.addEventListener('pjax:send', doSaveScroll);
document.addEventListener('pjax:send', doSaveScroll);
}
// Save the position by clicking the icon
link.addEventListener('click', () => {
Expand All @@ -49,7 +49,7 @@ document.addEventListener('DOMContentLoaded', () => {
});
});
scrollToMark();
window.addEventListener('pjax:success', scrollToMark);
document.addEventListener('pjax:success', scrollToMark);
};

init(CONFIG.bookmark.save);
Expand Down
2 changes: 1 addition & 1 deletion source/js/local-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
});
document.querySelector('.popup-btn-close').addEventListener('click', onPopupClose);
window.addEventListener('pjax:success', onPopupClose);
document.addEventListener('pjax:success', onPopupClose);
window.addEventListener('keyup', event => {
if (event.key === 'Escape') {
onPopupClose();
Expand Down

0 comments on commit 75695df

Please sign in to comment.