Opened 4 years ago

Closed 4 years ago

#31644 closed Cleanup/optimization (wontfix)

Add a change event to DateTimeShortcuts.js.

Reported by: Alton Ray Carlson II Owned by: nobody
Component: contrib.admin Version: 3.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

For the current DateTimeShortcuts.js, when you click on a date in the calendar and the date is copied into the textbox, no event fires. I have added in a few lines of code that will fire a change event for the textbox (DateField) that the calendar is associated with. On line 410, add this:

                if ("createEvent" in document) {
                    var evt = document.createEvent("HTMLEvents");
                    evt.initEvent("change", true, true);
                    DateTimeShortcuts.calendarInputs[num].dispatchEvent(evt);
                }
                else
                    DateTimeShortcuts.calendarInputs[num].fireEvent("onchange");

I have attached the file.

Attachments (1)

DateTimeShortcuts.js (20.1 KB ) - added by Alton Ray Carlson II 4 years ago.

Download all attachments as: .zip

Change History (2)

by Alton Ray Carlson II, 4 years ago

Attachment: DateTimeShortcuts.js added

comment:1 by Mariusz Felisiak, 4 years ago

Component: Uncategorizedcontrib.admin
Has patch: unset
Resolution: wontfix
Status: newclosed
Summary: Solution so that DateTimeShortcuts.js can fire a change event on its associated DateFieldAdd a change event to DateTimeShortcuts.js.

Thanks for this ticket, however IMO we shouldn't add events that would not be used in Django itself. Moreover you can always add events to calendar shortcuts on your own.

Note: See TracTickets for help on using tickets.
Back to Top