Skip to content

Commit 86f2c9d

Browse files
committed
cleand up and fixed ingredient edit table
1 parent c8eaa2a commit 86f2c9d

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

cookbook/templates/forms/edit_internal_recipe.html

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ <h3>{% trans 'Edit Recipe' %}</h3>
115115

116116
let ingredients = {{ ingredients|safe }}
117117

118-
ingredients.forEach(function (cur, i) {
119-
cur.delete = false
120-
});
118+
ingredients.forEach(function (cur, i) {
119+
cur.delete = false
120+
});
121121

122122
let data = ingredients;
123123

@@ -165,15 +165,6 @@ <h3>{% trans 'Edit Recipe' %}</h3>
165165
},
166166
{title: "id", field: "id", visible: false}
167167
],
168-
dataEdited: function (data) {
169-
$('#id_ingredients').val(JSON.stringify(data))
170-
171-
data.forEach(function (cur, i) {
172-
if (cur.delete) {
173-
table.deleteRow(cur.id);
174-
}
175-
})
176-
},
177168
cellClick: function (e, cell) {
178169
if (cell._cell.column.definition.editor === "input") {
179170
input = cell.getElement().childNodes[0];
@@ -183,6 +174,12 @@ <h3>{% trans 'Edit Recipe' %}</h3>
183174
},
184175
});
185176

177+
// save ingredient data before submitting form
178+
$('#id_form').submit(function () {
179+
$('#id_ingredients').val(JSON.stringify(table.getData()));
180+
return true;
181+
});
182+
186183
// load initial value
187184
$('#id_ingredients').val(JSON.stringify(data))
188185

0 commit comments

Comments
 (0)