From 7569b052f6aa96f0367ffcd94a844ea4458f719d Mon Sep 17 00:00:00 2001 From: 13hakta <13hakta@gmail.com> Date: Thu, 27 Apr 2023 18:27:28 +0500 Subject: [PATCH] Support django 4.1 dynamic formset addition event --- .../django-editorjs-fields/js/django-editorjs-fields.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/django_editorjs_fields/static/django-editorjs-fields/js/django-editorjs-fields.js b/django_editorjs_fields/static/django-editorjs-fields/js/django-editorjs-fields.js index c90cc0d..3daf7c8 100644 --- a/django_editorjs_fields/static/django-editorjs-fields/js/django-editorjs-fields.js +++ b/django_editorjs_fields/static/django-editorjs-fields/js/django-editorjs-fields.js @@ -162,8 +162,9 @@ // Event if (typeof django === "object" && django.jQuery) { - django.jQuery(document).on("formset:added", function (event, $row) { - var areas = $row.find("[data-editorjs-textarea]").get() + django.jQuery(document).on("formset:added", function (event, $row, formsetName) { + var areas = (event.detail && event.detail.formsetName)? + event.target.querySelectorAll("[data-editorjs-textarea]"):$row.find("[data-editorjs-textarea]").get() if (areas) { for (let i = 0; i < areas.length; i++) {