BUG: block render function not trigger
Question
@artf - In the documentation, it says that If we need to customize the aspect of each block preview we can pass a render callback function in the block.
But here is the actual thing Basically, I wrapped this render callback in a function named func() and calling it on some ajax request
If I call this on page load it works but if I try to call this func() function after page load on some click event/handler or API response this render callback inside that function doesn't trigger

Answers (1)
The block manager doesn't see the change if you do this block.attributes.render = ....
You have to update the property explicitly in this way:
block.set({
render: () => {
return `<div>NEW HTML</div>`
}
})
And be careful, the render function SHOULD return the HTML string or the DOM node, NOT a Promise. If you need to do something async, at first resolve it, THEN update the render with the returned content.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2762
[QUESTION] How to listen to trait value change directly from block add
I'm passing following JSON to editor.BlockManager.add() function to define my block, load it's content from the server and populate select-...
Issue #3309
BUG: TextNodes interfere when changing content on element
Version: 0.16.44 Hi @artf I have a custom block with a custom button component, which its content is similar to this one. <a data-gjs-type=...
Issue #3283
BUG: BlocksView rendering is being called twice
https://github.com/artf/grapesjs/blob/b199083f6a6128ecff41d20865493294f71fe0a1/src/block_manager/view/BlocksView.js#L186 The Block Manager...
Issue #2718
[QUESTION] Can't use i18n
Hi again @artf , you close my previous ticket but i don't succeed to reopen it i saw the documentation and the part reguarding i18n but i d...
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.