File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments