text: Opened 7 years ago
  Closed 7 years ago
  Last modified 6 years ago
  #16359 closed Cleanup/optimization (duplicate)
  Listen to click events from "Add another" admin inline link should be easier
  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.
  I agree that binding to those kind of events is a pain. The admin should definitly trigger namespaced events.
  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: