cleand up and fixed ingredient edit table
This commit is contained in:
parent
c8eaa2a349
commit
86f2c9d89c
@ -115,9 +115,9 @@
|
||||
|
||||
let ingredients = {{ ingredients|safe }}
|
||||
|
||||
ingredients.forEach(function (cur, i) {
|
||||
cur.delete = false
|
||||
});
|
||||
ingredients.forEach(function (cur, i) {
|
||||
cur.delete = false
|
||||
});
|
||||
|
||||
let data = ingredients;
|
||||
|
||||
@ -165,15 +165,6 @@
|
||||
},
|
||||
{title: "id", field: "id", visible: false}
|
||||
],
|
||||
dataEdited: function (data) {
|
||||
$('#id_ingredients').val(JSON.stringify(data))
|
||||
|
||||
data.forEach(function (cur, i) {
|
||||
if (cur.delete) {
|
||||
table.deleteRow(cur.id);
|
||||
}
|
||||
})
|
||||
},
|
||||
cellClick: function (e, cell) {
|
||||
if (cell._cell.column.definition.editor === "input") {
|
||||
input = cell.getElement().childNodes[0];
|
||||
@ -183,6 +174,12 @@
|
||||
},
|
||||
});
|
||||
|
||||
// save ingredient data before submitting form
|
||||
$('#id_form').submit(function () {
|
||||
$('#id_ingredients').val(JSON.stringify(table.getData()));
|
||||
return true;
|
||||
});
|
||||
|
||||
// load initial value
|
||||
$('#id_ingredients').val(JSON.stringify(data))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user