Issue for Map field output when page/content is loaded dynamically

Support General Issue for Map field output when page/content is loaded dynamicallyResolved

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #17924
    ambrdigitalambrdigital
    Participant

    Hi there,

    On our Contact page we are using the map field to output a Google map with our business on it. This loads just fine. However, when the page is loaded through AJAX dynamically (specifically using barba.js), the map does not output.

    There are no console errors, but it looks like the google maps scripts aren't being loaded into the DOM.

    Do you have a solution for loading the map field when it is called dynamically via AJAX? Let me know. Thank you so much

    #17945
    Anh TranAnh Tran
    Keymaster

    Hi,

    Can you try calling this JS after the page is loaded via Ajax:

    $( document ).trigger( 'mb_ready' );

    #17964
    ambrdigitalambrdigital
    Participant

    Hi Ahn,

    Thanks for the reply. Unfortunately that didn't seem to trigger the map or load the relevant scripts 🙁 any other ideas?

    #17985
    Anh TranAnh Tran
    Keymaster

    I see. Maybe you need to manually enqueue the Google maps script on the page before running the snippet above. Something like this:

    add_action( 'wp_enqueue_scripts', function() {
        RWMB_Map_Field::admin_enqueue_scripts( ['api_key' => 'your key', 'language' => 'en'] );
    } );
    #18129
    ambrdigitalambrdigital
    Participant

    Perfect, thank you!

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.