Issue #1817πŸ’¬ AnsweredOpened February 20, 2019by AkibDeraiya1230 reactions

Change HTML content while block is render in editor

Quick answerby artf

No @AkibDeraiya123 if you're trying to access the model from the script it means you've totally misunderstood its concept, please read carefully here https://grapesjs.com/docs/modules/Components-js.html#basic-scripts script is for the final HTML (where model, editor and GrapesJS don't exist) not the editor

Read full answer below ↓

Question

Hello @artf I have one block into block manager like As per above script inside the block, i want to add dynamic HTML content while this block is rendered into the UI. I know that i don't need to change DOM. But need to change using model, but i don't know how can i change it using mode by id/class. Can you please help me how can i achieve this?

Answers (3)

artfβ€’ February 22, 2019

No @AkibDeraiya123 if you're trying to access the model from the script it means you've totally misunderstood its concept, please read carefully here https://grapesjs.com/docs/modules/Components-js.html#basic-scripts script is for the final HTML (where model, editor and GrapesJS don't exist) not th...

AkibDeraiya123β€’ February 22, 2019

Thank you for the response @artf , So, it means i can't load dynamic content into blocks while it will render into the editor? If yes then how can i?

Can i replace whole block's html using this.innerHTML = 'New Html content'?

artfβ€’ February 22, 2019

Of course you can, but not via script property. You have to create a custom component and update there its model

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.