I’m having a problem with Shopify editor and a javascript module.
I’ve created a section for testimonials slider, everything is working except when I add more than 2-3 of these sections: every time I edit something (text, change image, select link) the Shopify editor freezes.
I found out that every time I select an image or write text (even if it’s another section) the slider.init() gets fired.
document.addEventListener("shopify:section:load", (e) => {
slider.init();
});
document.addEventListener("DOMContentLoaded", () => { slider.init() });
I’ve tried to only fire the slider if its section is loaded… but it doesn’t work.
document.addEventListener("shopify:section:load", function(e) {
if(e.detail.sectionId === '{{section.id}}') {
slider.init();
}
});
document.addEventListener("DOMContentLoaded", (e) => { slider.init() });
I’m out of ideas. Do you guys have a solution for this?
What I’m trying to achive:
- when the Shopify Editor is opened > start all “testimonials sliders”
- when a new “testimonials sliders” section is loaded > start the slider
- Prevent the Shopify editor from freezing because every time :load is fired it tries to re-fire slider.init()
thank you in advance
