Issue #3199Opened December 19, 2020by mohd74690 reactions

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

image

Answers (1)

artfDecember 30, 20200 reactions

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.

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...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.