How to bind events with jquery in django admin when adding a new * Inline

I created a jquery function that binds some fields, but it does not work when I add a new line.

The main problem is that I do not know how to define an insert in the DOM and bind it to my function.

thanks

+4
source share
3 answers

Use the live or delegate functions to bind to form elements. They will continue to work even after entering new form elements, and you do not need to re-attach event handlers every time.

Related questions:

+2
source
 $('.add-row a').click(my_function) 

while my_function does not include return false; , it should not interfere with the existing functions of this button

0
source

The above suggestions do not work for this particular problem. I will write an error and ask if they can assign an identifier to this link or fix it differently.

Edit: bug registered https://code.djangoproject.com/ticket/16359

0
source

Source: https://habr.com/ru/post/1309834/


All Articles