File tree Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Expand file tree Collapse file tree 1 file changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -115,9 +115,9 @@ <h3>{% trans 'Edit Recipe' %}</h3>
115
115
116
116
let ingredients = { { ingredients| safe } }
117
117
118
- ingredients . forEach ( function ( cur , i ) {
119
- cur . delete = false
120
- } ) ;
118
+ ingredients . forEach ( function ( cur , i ) {
119
+ cur . delete = false
120
+ } ) ;
121
121
122
122
let data = ingredients ;
123
123
@@ -165,15 +165,6 @@ <h3>{% trans 'Edit Recipe' %}</h3>
165
165
} ,
166
166
{ title : "id" , field : "id" , visible : false }
167
167
] ,
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
- } ,
177
168
cellClick : function ( e , cell ) {
178
169
if ( cell . _cell . column . definition . editor === "input" ) {
179
170
input = cell . getElement ( ) . childNodes [ 0 ] ;
@@ -183,6 +174,12 @@ <h3>{% trans 'Edit Recipe' %}</h3>
183
174
} ,
184
175
} ) ;
185
176
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
+
186
183
// load initial value
187
184
$ ( '#id_ingredients' ) . val ( JSON . stringify ( data ) )
188
185
You can’t perform that action at this time.
0 commit comments