Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4737 มุมมอง

I've designed a block that uses an external javascript library, which modifies the html structure. So I have to use the cleanForSave function (in a snippet options javascript file) to destroy the instance and undo all the DOM modifications before saving the html.

I would need a way to call that function (or a "hook") before saving in editor mode, even when the said block has not been edited/added (so the onStart/onBuilt/etc. functions have not been called).

อวตาร
ละทิ้ง
ผู้เขียน คำตอบที่ดีที่สุด

okay, got it
might seem obvious for some ppl, but had to figure it out myself : in a custom module, define a variable like :
var snippetEditor = require('webeditor.snippet.editor');

from there, you can override what you want :

snippetEditor.Editor.include({        cleanForSave: function (parent, target, templateOptions) {            $('.slick-slideshow.slick-initialized').slick('unslick');
            if (this.isDestroyed()) {                return;            }            _.each(this.styles, function (option) {                option.cleanForSave();            });        }    });



I needed to call that "slick" function, so everything is working good now

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
พ.ค. 23
3921
2
ธ.ค. 21
10805
1
มี.ค. 23
4552
1
มี.ค. 16
5662
0
ก.ค. 25
74