Wordpress interactivity to load one group, re-evaluate lightbox
19:42 13 Nov 2025

I have a block which dynamically updates a group. Its working, but, if the group content contains a lightbox for an image, it doesn't work. I see the lightbox indicator, but pressing it does not expand.

How do I get it to re-evaluate?

import { store, withSyncEvent, navigate } from '@wordpress/interactivity';

const { actions } = store( 'agilicus/agilicus-embed-block', {
        actions: {
                setHtml( target, html ) {
                    target.innerHTML = html;
                }
        },
} );

...
const url = event.target.attributes.post_url.value;
fetch( url, {
 method: 'GET',
 credentials: 'same-origin',
 headers: new Headers( {
  'Content-Type': 'application/json;charset=UTF-8',
 } ),
} )
.then( ( response ) => response.json() )
.then( ( response ) => {
 const grp1 = document.getElementById( 'agilicusEmbedBlock' );
 const html = `${ response.content.rendered }
`; actions.setHtml( grp, html ); } );

The content is indeed changing just fine, however, I think the lightbox was evaluated at original page load time.

wordpress lightbox interactivity-api