I need to listen to WooCommerce's custom events like wc_fragment_refresched
or added_to_cart
. But when creating a listener for those events via the native addEventListener
nothing happens. But jQuery's .on()
works fine.
Working:
jQuery(document.body).on('wc_fragments_refreshed', function() {
console.log("hehey!");
});
Not working:
document.body.addEventListener('wc_fragments_refreshed', function() {
console.log("hoho!");
});
Does anyone have a clue why the native listener isn't working?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…