File tree Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ class Editor extends Field
1818
1919 public function render ()
2020 {
21- $ name = $ this ->formatName ($ this ->column );
2221 $ id = $ this ->formatName ($ this ->id );
2322
2423 $ config = (array ) WangEditor::config ('config ' );
@@ -31,19 +30,26 @@ public function render()
3130 $ token = csrf_token ();
3231
3332 $ this ->script = <<<EOT
33+ (function ($) {
3434
35- var E = window.wangEditor
36- var editor = new E('# {$ this ->id }');
37-
38- editor.customConfig.uploadImgParams = {_token: ' $ token'}
39-
40- Object.assign(editor.customConfig, {$ config })
41-
42- editor.customConfig.onchange = function (html) {
43- $('#input- $ id').val(html);
44- }
45- editor.create()
35+ if ($('# {$ this ->id }').attr('initialized')) {
36+ return;
37+ }
4638
39+ var E = window.wangEditor
40+ var editor = new E('# {$ this ->id }');
41+
42+ editor.customConfig.uploadImgParams = {_token: ' $ token'}
43+
44+ Object.assign(editor.customConfig, {$ config })
45+
46+ editor.customConfig.onchange = function (html) {
47+ $('#input- $ id').val(html);
48+ }
49+ editor.create();
50+
51+ $('# {$ this ->id }').attr('initialized', 1);
52+ })(jQuery);
4753EOT ;
4854 return parent ::render ();
4955 }
You can’t perform that action at this time.
0 commit comments