-
Notifications
You must be signed in to change notification settings - Fork 588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ws:init not working #159
Comments
window.ws = new WebSlides({
changeOnClick: true,
loop: false,
});
window.ws.el.addEventListener('ws:init', function (e) {
console.log("ws:init");
}); |
@Antonio-Laguna @jlantunez Is this possibly a regression? |
I don't think so since this hasn't changed. I think the event has fired by the time you're attaching the event listener. Do it like this: document.body.addEventListener('ws:init', function (e) {
console.log("ws:init");
});
window.ws = new WebSlides({
changeOnClick: true,
loop: false,
}); |
Can you update docs? (in repo's wiki) |
Added a note there. |
Thanks |
@Antonio-Laguna your suggestion doesn't work. |
The docs state: So I tried your suggestion on the element too and still didn't work. (window.ws doesn't exist at this point.) window.ws.el.addEventListener('ws:init', function (e) {
console.log("ws:init");
}); // window.ws doesn't exist at this point.
window.ws = new WebSlides({
changeOnClick: true,
loop: false,
});
|
Needs to go as I wrote above. The event bubbles so it'll reach the body. |
@Antonio-Laguna I tried what you wrote: document.body.addEventListener('ws:init', function (e) {
console.log("ws:init");
});
window.ws = new WebSlides({
changeOnClick: true,
loop: false,
}); It doesn't work. |
Can we reopen this? |
For future readers, here is my work-around. It's a dirty hack but works. Add this after your code. <script type="text/javascript" defer>document.body.dispatchEvent(new Event('ws:init'));</script> |
Sure! |
It appears that
ws:init
event is not workingThe text was updated successfully, but these errors were encountered: