[Django] #31644: Solution so that DateTimeShortcuts.js can fire a change event on its associated DateField

3 views
Skip to first unread message

Django

unread,
May 30, 2020, 2:47:20 PM5/30/20
to django-...@googlegroups.com
#31644: Solution so that DateTimeShortcuts.js can fire a change event on its
associated DateField
------------------------------------------------+------------------------
Reporter: arc720 | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Uncategorized | Version: 3.0
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
------------------------------------------------+------------------------
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.

--
Ticket URL: <https://code.djangoproject.com/ticket/31644>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 30, 2020, 2:47:58 PM5/30/20
to django-...@googlegroups.com
#31644: Solution so that DateTimeShortcuts.js can fire a change event on its
associated DateField
-------------------------------------+-------------------------------------
Reporter: arc720 | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Uncategorized | Version: 3.0
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by arc720):

* Attachment "DateTimeShortcuts.js" added.

Reply all
Reply to author
Forward
0 new messages