Ajax Woocomerce single product load gallery

Discussion in 'Anneliese' started by Naires, Jan 29, 2018.

  1. Naires

    Naires New Member

    Joined:
    Jan 29, 2018
    Messages:
    1
    Likes Received:
    0
    Hi,
    I need to use woocommerce in this theme. I already made the css and some custom functions that i need to the theme, but i'm stuck with one issue: I want to use the Ajax navigation (load pages) native functions, but the woocommerce 3.0 gallery doesn't load. I think i have to make the callback that load the gallery in your anneliese.ajax.js, but where? Can you help me with this issue?

    I think the key is within the implementation of this lines of code (more or less)

    Code (Javascript):
    $( '.woocommerce-product-gallery.images', data ).each( function() {
        $( this ).wc_product_gallery();
    } );
    thanks
     
  2. maimairel

    maimairel Administrator
    Staff Member

    Joined:
    Apr 16, 2014
    Messages:
    1,625
    Likes Received:
    61
    Hello,

    You can listen to this event:

    Code (Javascript):
    _win.on( 'anneliese:afterAjaxSetup', function( event, dom, response ) {} );
    Where response is the elements loaded via ajax. So you can for example do this:

    Code (Javascript):
    $( '.woocommerce-product-gallery.images', response ).each( function() {
        $( this ).wc_product_gallery();
    } );
    Thanks!
     

Share This Page