Support

Account

Home Forums Gutenberg Dispatch Javascript event on acf/ajax/render_block_preview success

Solving

Dispatch Javascript event on acf/ajax/render_block_preview success

  • You beta with Gutenberg support is excellent! Suggestion, I would like to subscribe to an event when new block data is loaded with ajax action: acf/ajax/render_block_preview

    This would allow me to e.g. re-instantiate my module via Javascript (let’s say it’s a React or Vue component).

    Thanks

  • It’s been quite a while since this was originally posted but I would also love to see this type of event added. I have a few blocks that use their own custom JS events and it would be great to be able to initialize those for the user when previewing the block in the admin.

  • Actually, I spoke too soon. Looks like there is already a JS event in ACF Pro for handline this situation. The event is:

    render_block_preview

    It passes two arguments, the element as a jQuery object and details about the block (name, content, mode, etc…). I put together a quick example usage here:

    https://gist.github.com/hereswhatidid/a67dc3697a481c223bdced42586f6664

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.