1
I’m doing some tests, and, I have some custom events on the platform I use, however, the window.addeventlistener does not work according to the on() of jQuery.
the event I use, let’s assume that the name is shoppingCartUpdated, it is triggered through the window.
As I do this in jQuery, it works normally
$(window).on('shoppingCartUpdated', function(e){
console.log(e);
})
However, with addeventlistener, no.
window.addEventListener('shoppingCartUpdated', function(e){
console.log(e);
});
I know they work differently, because otherwise jQuery’s people wouldn’t create the on. But, I’ve tried some ways to look at the source code of jQuery and I don’t quite understand how it works. It is possible to reproduce the same effect?
When I say "work", I mean that with jQuery I printed the console.log, with addEventListner no.
What is the
evt
that you passed to theaddEventListener
?– Woss
@Woss sorry, I edited. Now it’s right.
– Lucas de Carvalho
Another question: this your custom event,
shoppingCartUpdated
, is a Bubble Event? I mean, does it spread to the parent elements of the original target of the event? It would be interesting if you [Dit] the question and add information on how you created and fired the event.– Woss
@Woss as is the platform "Saas" that made this event, and not me, I can’t tell you that. I can know this information by some output on jQuery’s console? Can I paste what jQuery returns here...
– Lucas de Carvalho
Any extra information might be helpful... put what you can of event information in the question
– Woss
How are you running the Rigger’s
shoppingCartUpdated
with pure Javascript?– Guilherme Nascimento
If it’s of interest, I commented on the operation of
jQuery.on
in Events do not work with dynamic video?– Woss