Function does not start by itself (on pageload)
-
Hi all,
I would like an animation to autostart on page load. I’m in the Onsen UI V2 JS Splitter example within the ons-template in an ons-page.I found that adding a script tag between the “/ons-page” and the “/ons-template” tags gets read (this took me quite some time… (-; )
I added this:
document.addEventListener("init", function(event) { if (event.target.id == "score.html") { Progress1(); } }, false);
Nothing happened.
I added this
setTimeout(function(){ Progress1(); }, 3000);
The function starts! (thank you @Andi ) But only the first time the page is opened. The second time: nothing happens. On reload it usually works (not always).
I added a button that called the function
</ons-toolbar-button> </div> <div class="right"> <ons-toolbar-button onclick="Progress1()"> <ons-icon icon="md-menu"></ons-icon> </ons-toolbar-button>
This always works.
Any ideas why the function won’t start and what to do about it?
thanks
Remco
-
@Remco-Koffijberg Hello! The page is only initialized once, so
init
event won’t work for you. You can try withshow
event instead.
-
Aha, that clarifies something. (-; But it doesn’t do anything though.