Support

Account

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”