Issue #2523💬 AnsweredOpened January 22, 2020by MatejGlasnak0 reactions

Class selector set to active: false not working properly

快速解答by MatejGlasnak

I found solution. Selector:add is called only when new component is added, but selector settings for that component wont save. After page reload it wont be called to previously saved components so they will have default value (true). To fix this problem, call this after components has been loaded. editor.SelectorManag...

Read full answer below ↓

Question

Hi i set: editor.on('selector:add', selector => selector.set({ active: false, }));

to NOT select class on element after click and editing css, it is working but after page refresh it is selecting element's classes again. Is there any way to fix it?

Answers (1)

MatejGlasnakJanuary 23, 2020

I found solution. Selector:add is called only when new component is added, but selector settings for that component wont save. After page reload it wont be called to previously saved components so they will have default value (true). To fix this problem, call this after components has been loaded.

editor.SelectorManager.getAll().map(selector => { selector.set({ active: false }) })

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.