Snippets

Oscar García Arenas pantheoneaudio MutationObserver

Created by Oscar García Arenas
;( function($) {
	const targetNode = document.getElementById('wrapper');
	const config = { attributes: false, childList: true,  subtree: false };
	const callback = function(mutationsList, observer) {
    	if ( $('.wcpbc-price.loading').length ) {
			$(document.body).triggerHandler('wc_price_based_country_ajax_geolocation');
			observer.disconnect();
    	}
	};

	// Create an observer instance linked to the callback function
	const observer = new MutationObserver(callback);

	$(document.body).on( 'wc_price_based_country_after_ajax_geolocation', function() {
		// Start observing the target node for configured mutations
		observer.observe(targetNode, config);
	});
	observer.observe(targetNode, config);
})(jQuery);

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.