Skip to content

Commit cee3869

Browse files
authored
Create for loop to initialize multiple textareas
In some applications there may be multiple textareas to add in a form.
1 parent d1f4890 commit cee3869

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

django_editorjs_fields/static/django-editorjs-fields/js/django-editorjs-fields.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,12 @@
163163
// Event
164164
if (typeof django === "object" && django.jQuery) {
165165
django.jQuery(document).on("formset:added", function (event, $row) {
166-
var textarea = $row.find("[data-editorjs-textarea]").get(0)
166+
var areas = $row.find("[data-editorjs-textarea]").get()
167167

168-
if (textarea) {
169-
initEditorJsField(textarea)
168+
if (areas) {
169+
for (let i = 0; i < areas.length; i++) {
170+
initEditorJsField(areas[i])
171+
}
170172
}
171173
})
172174
}

0 commit comments

Comments
 (0)