diff roundup/cgi/templating.py @ 5179:e8b3d3a14563

- issue2550796: Calendar and Classhelp selection tools don't cause onchange event to be triggered. Using the helper popups for modifying lists of users, lists of issues, dates etc.. now trigger the change event on the form's field. This allows onchange javascript to trigger to highlight changes, recalculate other form values etc. See ``upgrading.txt`` for details on applying these changes to your tracker.
author John Rouillard <rouilj@ieee.org>
date Sat, 28 Jan 2017 20:58:19 -0500
parents fac171f0f27b
children f95650727b1c
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Tue Jan 24 16:58:05 2017 +1100
+++ b/roundup/cgi/templating.py	Sat Jan 28 20:58:19 2017 -0500
@@ -3083,8 +3083,9 @@
         for week in calendar.monthcalendar(display.year, display.month):
             res.append('  <tr>')
             for day in week:
-                link = "javascript:form[field].value = '%d-%02d-%02d'; " \
-                      "window.close ();"%(display.year, display.month, day)
+                 link = "javascript:form[field].value = '%d-%02d-%02d'; " \
+                      "if ('createEvent' in document) { var evt = document.createEvent('HTMLEvents'); evt.initEvent('change', true, true); form[field].dispatchEvent(evt); } else { form[field].fireEvent('onchange'); }" \
+                       "window.close ();"%(display.year, display.month, day)
                 if (day == curr_date.day and display.month == curr_date.month
                         and display.year == curr_date.year):
                     # highlight

Roundup Issue Tracker: http://roundup-tracker.org/