Skip to content

Commit

Permalink
fix: Prevent datetimeshortcuts from rendering multiple times (#129)
Browse files Browse the repository at this point in the history
This was happening because scripts injected inside
`$(document).ready(...)` would delay onload event and django's
DateTimeShortcuts script attaches an event handler to `load` event to
initialize the widgets. What would happen is our own initialization
would run first and the one coming from django second resulting in
duplicate widget. This change ensures our initialization happens last.

See #128
  • Loading branch information
vxsx authored Aug 16, 2024
1 parent 4747840 commit 311197f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rangefilter/templates/rangefilter/date_filter.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
});
}

django.jQuery('document').ready(function () {
django.jQuery(window).on('load', function () {
if (!('DateTimeShortcuts' in window)) {
var promiseList = [];

Expand Down
2 changes: 1 addition & 1 deletion rangefilter/templates/rangefilter/date_filter_4_0.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ <h3>{{ title }}</h3>
});
}

django.jQuery('document').ready(function () {
django.jQuery(window).on('load', function () {
if (!('DateTimeShortcuts' in window)) {
var promiseList = [];

Expand Down

0 comments on commit 311197f

Please sign in to comment.