Support

Account

Home Forums Gutenberg How to re-trigger a blocks JS when updating the block fields

Helping

How to re-trigger a blocks JS when updating the block fields

  • Hello,

    I’m hoping someone can help me out here.

    I’m making a block using ACF that my client can use as a full width section on her homepage. It is a google map with custom pins showing her 3 shop locations in the city. (The pin locations are sourced from last/long fields in the Locations CPT). So the only thing my client can change in this block is the title which is positioned absolutely on top of map. (Eg. ‘Come and say hi’)

    All works great on the front end. However, on the backend, if my client updates the title of this block, the map preview in the block disappears.

    I’m pretty sure this is because it’s not re-firing the enqueued JS file which initiates the map.

    I’ve spent HOURS trying to figure this out. However the closest I’ve got is to re-fire the JS when the client detects new AJAX requests. But this of course fires on changes to all block, auto save etc. And even this doesn’t work each time the title field is updated.

    Clearly there is some JS at work to repaint the updated title field in the block preview. So my question is, does anyone know how to hook into this to also fire the map JS again?

    My client is adamant she wants to see the map in the block preview as she sees it on the front end. So its not ideal that the map preview disappears when she updates the block title field.

    Bottom line is I need to get this working somehow so any help would be very gratefully received!

    Many thanks,

    Richard

  • I’m having the exact same issue. Any help?

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

You must be logged in to reply to this topic.