Rilegatura e innescando nativi e personalizzati eventi in Prototype
-
24-10-2019 - |
Domanda
Sto avendo un po 'di problema con gli eventi in prototipo.
Sto cercando di legare e sparare gli eventi nativi: onhashchange
e onpopstate
. Così come i miei eventi personalizzati: statechange
e anchorchange
. Tutti questi eventi sono per l'elemento window
.
Ecco il codice che ho già provato senza fortuna:
Element.observe(window,eventName,eventHandler);
Element.fire(window,eventName);
Qualsiasi aiuto sarebbe apprezzato.
Soluzione 2
I ended up coming up with this: https://gist.github.com/796871
Which allows a consistent API for custom and standard events.
Altri suggerimenti
You can only use fire for custom events.
Take a look at this question/answer. I think it solves your problem. It's certainly what we use.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow