File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -65,10 +65,11 @@ public function run()
6565 private function registerAssets ()
6666 {
6767 $ ajaxUrl = Url::to ($ this ->ajaxUrl );
68- $ jsonEditorContainerId = Html::getInputId ($ this ->model , $ this ->jsonEditorAttribute ) . '-container ' ;
68+ $ jsonEditorInputId = Html::getInputId ($ this ->model , $ this ->jsonEditorAttribute );
69+ $ jsonEditorContainerId = $ jsonEditorInputId . '-container ' ;
6970 $ select2Id = Html::getInputId ($ this ->model , $ this ->attribute );
7071 $ jsonEditorOptions = json_encode ($ this ->jsonEditorOptions );
71-
72+
7273 $ this ->view ->registerJs (<<<JS
7374$("# {$ select2Id }").on("select2:select", function () {
7475 var value = $(this).val();
@@ -89,6 +90,10 @@ private function registerAssets()
8990
9091 jsonEditors[index].destroy();
9192 jsonEditors[index] = new JSONEditor(document.getElementById(" {$ jsonEditorContainerId }"), jsonEditorOptions)
93+
94+ jsonEditors[index].on("change", function () {
95+ document.getElementById(" {$ jsonEditorInputId }").value = JSON.stringify(this.getValue());
96+ })
9297 }
9398 })
9499});
You can’t perform that action at this time.
0 commit comments