Skip to content

Commit 25684f0

Browse files
committed
Fix pagedown bugs
1 parent 9c01ec8 commit 25684f0

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

resources/common.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,20 @@ function submitFormWithParams($form, method) {
426426
}
427427
}
428428

429+
function initPagedown(maxRetries=5) {
430+
let attempts = 0;
431+
432+
function tryInit() {
433+
if ('DjangoPagedown' in window) {
434+
DjangoPagedown.init();
435+
} else if (attempts < maxRetries) {
436+
attempts++;
437+
setTimeout(tryInit, 1000);
438+
}
439+
}
440+
441+
tryInit();
442+
}
429443

430444
function navigateTo(url, reload_container, force_new_page=false) {
431445
if (url === '#') return;
@@ -484,9 +498,7 @@ function navigateTo(url, reload_container, force_new_page=false) {
484498

485499
$(document).prop('title', $(data).filter('title').text());
486500
renderKatex($(reload_container)[0]);
487-
if ('DjangoPagedown' in window) {
488-
DjangoPagedown.init();
489-
}
501+
initPagedown();
490502
onWindowReady();
491503
registerNavList();
492504
$('.xdsoft_datetimepicker').hide();

resources/darkmode-svg.css

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/course/edit_lesson.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@
2323

2424
$(this).val(selectedValues);
2525
});
26-
setTimeout(function() {
27-
if ('DjangoPagedown' in window) {
28-
DjangoPagedown.init();
29-
}
30-
}, 2000);
3126
});
3227
</script>
3328
{% endblock %}

0 commit comments

Comments
 (0)