Issue #3363πŸ’¬ AnsweredOpened March 24, 2021by nairdapuiu1 reactions

Set content function empties the component content

Quick answerby artf❀ 1

you shouldn't use the content property, use selectedComponent.components(str)

Read full answer below ↓

Question

I am trying to use the set function to change the content of a component, but actually the result is an empty component with nothing inside. This is an example with the code summarized Version used: 0.16.44 What is the expected behavior? The code executed should result in a component with text "foo" inside. What is the current behavior? The executed code empties the component content. In version 0.16.34 everything works as expected. Is there an workaround for this issue or should i stick with 0.16.34 verison ?

Answers (2)

artfβ€’ March 24, 2021

you shouldn't use the content property, use selectedComponent.components(str)

GJSBlockβ€’ May 17, 2026

Thanks for reporting this, @nairdapuiu. Great question about Set content function empties the component content. The recommended approach with Components is to use the event-driven API. Start here: Check the GrapesJS documentation for your specific module Look for the on() event listener method Mos...

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 β†’

Related tutorials

In-depth guides on the same topic.

All tutorials β†’

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.