File tree 1 file changed +18
-12
lines changed
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
18
18
19
19
public function render ()
20
20
{
21
- $ name = $ this ->formatName ($ this ->column );
22
21
$ id = $ this ->formatName ($ this ->id );
23
22
24
23
$ config = (array ) WangEditor::config ('config ' );
@@ -31,19 +30,26 @@ public function render()
31
30
$ token = csrf_token ();
32
31
33
32
$ this ->script = <<<EOT
33
+ (function ($) {
34
34
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
+ }
46
38
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);
47
53
EOT ;
48
54
return parent ::render ();
49
55
}
You can’t perform that action at this time.
0 commit comments