Issue #518💬 AnsweredOpened November 14, 2017by HarshOB0 reactions

Change only component body not whole page body.

Quick answerby artf

You can replace the content of the model

Read full answer below ↓

Question

Hello @artf

As we discussed in issue #374. setComponents will set the body and replace all the contents that are present on the page with a new select page from the list. What if I want to set the body to only that component without changing the whole content of the page?

Answers (3)

artfNovember 15, 2017

You can replace the content of the model

// model could be, for instance, editor.getSelected()
model.components('<div>Text 1</div><div>Text 2</div>')
HarshOBNovember 17, 2017

How can I replace the content of a component with specific value like "Hello"?

artfNovember 17, 2017

Tried with this model.components('Hello')?!?

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.