Possible Ajax Loop Bug
-
Hi, I have found what appears to be a bug in the free version of Yith WishList I think you may be interested in.
I am performing an Ajax request on the single product page to load new upsell products after a variation change with;
$(document).on(‘found_variation’, ‘form.cart’, function (event, variation) {
self.getUpsells(event, variation);
});As part of my getUpsells() method, I do $(document).trigger(‘yith_wcwl_reload_fragments’); to populate the add to wishlist button on the new products which is handled on line 493 of jquery.yith-wcwl.js
load_fragments() amongst other things triggers $(document).trigger( ‘yith_wcwl_fragments_loaded’, [ fragments, data.fragments ] );
Which in turn is handled by the following, on lines 502-504 of jquery.yith-wcwl.js;
t.on( ‘yith_wcwl_fragments_loaded’, function( ev ){
$( ‘.variations_form’ ).find( ‘.variations select’ ).last().change();
} );The above lines seem to trigger WooCommerce to reload the variation which in turn triggers my initial method listening on “found_variation” and the whole thing goes into a loop.
I can’t see what lines 502 to 504 are needed for and removing them does not seem to stop anything from working correctly, is it leftover code?
Am I using the correct trigger to populate the wishlist button “yith_wcwl_reload_fragments” post ajax event
Do you have any advice on whether or not this is the correct way to handle such an event?
The topic ‘Possible Ajax Loop Bug’ is closed to new replies.