Issue #906💬 AnsweredOpened February 28, 2018by ciotuvasile0 reactions

How to change custom component content (html) from ajax?

Quick answerby artf

The components() method is the way to go to change the inner content editor.getSelected().components('<div>New inner content</div>'); but take care that with editor.getSelected().toHTML() you're getting the outer content (with its component tag)

Read full answer below ↓

Question

Hi @artf, First of all thanks for this awesome plugin. Can you please let me know how i can update/change block content? I created custom block + component. <table><tr><td class="some-class">texttoreplace</td></tr></table> Component has new toolbar button (search icon in attached screenshot) and on click i get new info like productname etc. So, i get current block html, do all stuff ... How can i update selected block html to new text? something like editor.getSelected().setHTML(newhtml); If i try to change from Model Block code look like this: I also tried but seems is added new component in...

Answers (2)

artfApril 15, 2018

The components() method is the way to go to change the inner content editor.getSelected().components('<div>New inner content</div>'); but take care that with editor.getSelected().toHTML() you're getting the outer content (with its component tag)

lock[bot]September 17, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

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.