Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
Page Beforeshow event???
-
Hi, is there a way to trigger an event just before a page is shown?. The event “init” does not work for me, because it is executed only one time. Event “show” does not work either, because as all is already shown, I get a horrible flickering after I do any change.
-
If you’re using ons-navigator to move between pages,
prepush
andprepop
might do the trick.https://onsen.io/v2/api/js/ons-navigator.html#events-summary
-
@emccorson said in Page Beforeshow event???:
prepush
Its ok, thanks!. However I don’t find any the way to get the page id of the page being pushed. “getCurrentPage” does not work at this point, and event.currentPage neither. How can I get the page being pushed??? Thanks!
-
I think that information is not included in the event object for some reason, but it probably should be.
You can pass the page id in the data object when calling
pushPage
:document.querySelector('#myNavigator').pushPage('page2.html', {data: {id: 'page2.html'}});
-
This post is deleted!
-
Thanks, This is the situation: I need to assign “HELLO” to a input text, but just before the page is shown, thus avoid the flickering of the text. When I use the event “prepush”, seems that my text element is not available in the DOM! and the console shows a red error. How can I assign data to my elements before the page is shown? "
PD: postpush" does work, but I get the same flickering as with “show”.
-
If you push a page, pop it, and then push it again, the
init
event is fired again on the second push. You can see it working in this example if you do aconsole.log
on the init event: https://onsen.io/playground/?framework=vanilla&category=reference&module=navigatorThis should make it possible to use the
init
event to do what you want.
-
Yes!..My problem was that my reference was Jquery Mobile, in their case INIT is executed only once per session…So if you go back, INIT does not get triggered…and YES, I m migrating my APP from JQM to ONSEN. Thanks! your support is awesome!