Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4843 Vizualizări

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).

Imagine profil
Abandonează
Autor Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
1
mai 23
4036
2
dec. 21
10919
1
mar. 23
4752
1
mar. 16
5758
0
iul. 25
324