Dynamically adding a form to a Django formset with Ajax

后端 未结 15 1907
不思量自难忘°
不思量自难忘° 2020-11-22 03:09

I want to automatically add new forms to a Django formset using Ajax, so that when the user clicks an \"add\" button it runs JavaScript that adds a new form (which is part o

15条回答
  •  [愿得一人]
    2020-11-22 03:26

    @Paolo Bergantino

    to clone all the handlers attached just modify the line

    var newElement = $(selector).clone();
    

    for

    var newElement = $(selector).clone(true);
    

    to prevent this problem.

提交回复
热议问题