#16359 closed Cleanup/optimization (duplicate)
Listen to click events from "Add another" admin inline link should be easier
Reported by: | Owned by: | Michael Manfre | |
---|---|---|---|
Component: | contrib.admin | Version: | 1.3 |
Severity: | Normal | Keywords: | admin, javascript, event, add another |
Cc: | dguardiola@… | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When creating custom fields for django admin inlines, it is handy to be able to listen to an even fired by clicking on "add another". I would like to listen to the click event to initiate my jquery plugin and pass it some parameters. Currently this is (to my knowledge) not possible. When binding the click event to it, it doesn't work:
$('a').live('click', function() { console.log('add clicked'); });
Also binding click to .add-row doesn't work. Apparently some other script (admin/js/inlines.min.js) which listens to the same element returns false.
To make this work inlines.min.js should not return false, or raise another event.
To make it more easy to work with, the link should get an id like #row-add-another.
Change History (4)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Keywords: | admin javascript event add another added |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 13 years ago
Resolution: | → duplicate |
---|---|
Status: | assigned → closed |
This is a duplicate of #15760, which also has a patch.
comment:4 by , 12 years ago
Cc: | added |
---|
I agree that binding to those kind of events is a pain. The admin should definitly trigger namespaced events http://api.jquery.com/trigger/.
So far I've managed to workaround this issue by binding ".add-row a" click event and/or binding the DOMNodeInserted event which is not pretty: