Home › Forums › Gutenberg › acf.Model event when changing from edit to preview mode › Reply To: acf.Model event when changing from edit to preview mode
The answer is this simple bit of code (https://gist.github.com/hereswhatidid/a67dc3697a481c223bdced42586f6664):
if( window.acf ) {
window.acf.addAction( 'render_block_preview/type=accordion', function( $elem, blockDetails ) {
initializeElement( $elem );
} );
}
And this bit from this article helps if you change the namespace to target your block(https://www.billerickson.net/building-acf-blocks-with-block-json/):
“If you use a namespace other than “acf/” you need to use the full block name in the callback, so: render_block_preview/type=cwp/tip”
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.