Skip to content

Commit 62d35c9

Browse files
committed
refactored jsonEditor init with cleaned startval
1 parent 9187c5f commit 62d35c9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

assets/backend/page-route-items.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,22 @@ $(function () {
2323
// we only want to change schema, so get defined options from current editor.
2424
var editorOptions = editor.options;
2525
editorOptions.schema = JSON.parse(schema);
26+
// reset startval && make all "new" options required in schema
27+
editorOptions.startval = {};
28+
editorOptions.required_by_default = true;
2629
// recreate Editor
2730
editor.destroy();
2831
jsonEditorList[editorIndex] = new JSONEditor(element, editorOptions);
2932
jsonEditorList[editorIndex].on('ready', function () {
3033
// inital update of value
31-
$('input[name="Tree[request_params]"]').val(JSON.stringify(jsonEditorList[editorIndex].getValue()));
32-
33-
// update/init change callback for newly inserted editor which update the input value
34-
jsonEditorList[editorIndex].on('change', function () {
35-
$('input[name="Tree[request_params]"]').val(JSON.stringify(jsonEditorList[editorIndex].getValue()));
36-
});
34+
$('input[name="Tree[request_params]"]').val(JSON.stringify(this.getValue()));
35+
});
36+
// update/init change callback for newly inserted editor which update the input value
37+
jsonEditorList[editorIndex].on('change', function () {
38+
$('input[name="Tree[request_params]"]').val(JSON.stringify(this.getValue()));
3739
});
3840

41+
3942
} else {
4043
console.error('Editor not found.');
4144
}

0 commit comments

Comments
 (0)