Support

Account

Forum Replies Created

  • Finally got this one solved. In my case, I was enhancing the WooCommerce Quick View Pro plugin. That plugin does not create a modal until AFTER the DOM has been rendered. However, the ACF jQuery file is loaded in the DOM before the modal is created. The solution for Quick View Pro is to load that jQuery after we generate the HTML.

    I solved this by including the jQuery, e.g., after the ACF div containers were rendered. Here’s an example:

      /*
       * Display a map (saved from Advanced Custom Fields) in Quick View Pro modal
       * Documentation: https://battlestardigital.com/adding-advanced-custom-fields-google-maps-to-woocommerce-quick-view-pro/
       * HTML Source: https://www.advancedcustomfields.com/resources/google-map/
      */
      private function bsd_qvp_display_map( $map) {
        if ( $map ) {
          ?>
          <div id="map" class="acf-map">
            <div class="marker" data-lat="<?php echo esc_attr($map['lat']); ?>" data-lng="<?php echo esc_attr($map['lng']); ?>"></div>
          </div>
          <script>
          <?php        
            include_once get_stylesheet_directory() . '/bsd-maps.js'; // Assumes you've made a copy of the ACF JavaScript field and placed it in your child theme folder
            //include_once dirname( BSD_WC_QVP_PATH ) . '/assets/bsd-maps.js'; // Use this syntax if you're storing the file elsewhere, e.g., your plugin
          ?>
          </script>
          <?php      
        }
        
      }
    

    P.S. The link to my test site changed to https://wp.battlestardigital.com/quick-view-pro-test-page/

  • Changing order of element addition did not make a difference.

    I found this thread: google-maps-does-not-load-in-a-bootstrap-modal, where the author posted the following code to resolve the issue:

    // popup is shown and map is not visible
    google.maps.event.trigger(map, 'resize');

    I’m not a jQuery guy. Working on figuring out where to paste this; advice requested!

  • I realize this is an old thread, but where specifically did you paste this code? It may fix an issue I’m having.

  • Update: I believe it may be related to the order in which I add elements to the modal. Will continue to research and update here accordingly.

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