Opened 10 years ago

Closed 10 years ago

#24406 closed Cleanup/optimization (fixed)

SelectFilter should use click events instead of href javascript functions

Reported by: Rolf Jagerman Owned by: Rolf Jagerman
Component: contrib.admin Version: dev
Severity: Normal Keywords: admin SelectFilter javascript
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Rolf Jagerman)

SelectFilter uses javascript in an href to handle button behavior:

<a href="javascript:function(){...}">

This is problematic if one wishes to customize the widget, since the href javascript is executed after events are handled. It would be better to use a click event to handle this type of behavior:

someElement.addEventListener("click", function() { ... } );

I have proposed a patch on github:

https://github.com/django/django/pull/4205
https://github.com/rjagerman/django/tree/ticket_24406
https://github.com/rjagerman/django/commit/e07a0be20d6da81794eaa5b64c2927cc6c70410d

Attachments (1)

selectfilter.diff (4.0 KB ) - added by Rolf Jagerman 10 years ago.
SelectFilter2.js git diff

Download all attachments as: .zip

Change History (5)

by Rolf Jagerman, 10 years ago

Attachment: selectfilter.diff added

SelectFilter2.js git diff

comment:1 by Rolf Jagerman, 10 years ago

Description: modified (diff)

comment:2 by Rolf Jagerman, 10 years ago

Owner: changed from nobody to Rolf Jagerman
Status: newassigned

comment:3 by Rolf Jagerman, 10 years ago

Description: modified (diff)

comment:4 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In fa9cb5dcdc816fe0e606b8f1020d53526e08b0d4:

Fixed #24406 -- Improved SelectFilter js to use click events

The SelectFilter widget used href to execute javascript. This was
problematic if one wishes to customize the widget, since the href
javascript is executed after events are handled. This change modifies
the javascript to use click events to handle button behavior.

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