change only component body not whole page body.
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)
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>')
How can I replace the content of a component with specific value like "Hello"?
Tried with this model.components('Hello')?!?
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1247
Text disappear after creating a new type
Hello! I am creating a new block that will open a modal during the creation (drag and drop https://github.com/artf/grapesjs/issues/174 real...
Issue #964
Component properties configuration
@artf Sorry to post it again, It will be the continuation of #952 I just discussed the approach with MJML community and our conversation we...
Issue #1113
[QUESTIONS] New trait type is not working with rendered components?
Hello, thanks for the great framework. I'm trying to apply this to my project. I want to add a new trait for existing LINK '<a>' component....
Issue #980
[BUG] Related with task https://github.com/artf/grapesjs/issues/873
Hello, After restoring editor from db still have some part of bug present. It seems inside of script: function () traits will have old valu...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.