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.
Need clarification on Navigator events
OnsenUI 2, latest beta
I am using a stack of pages and the “standard” navigator events (as per the documentation), are “pre/post push” and “pre/post pop”. I’ve been also using “show” and “init”, though (on the navigator itself).
I need to attach behaviours to the elements on the page (clicks, for example), plus I need to fill in some of the elements with data.
Now I am not sure where I should attach that logic: apparently, the “show” event is fired before the init (which seems weird to me).
Question is: using the navigator events, when is that I could be sure that the page has been inserted in the DOM and when should I need to use the “show” event, if I need it?
When you say the latest beta you mean the latest released beta (beta.9) or the nightly build (beta.10)? The issue about
showevent being fired before
initwas fixed in beta.10.
I think that if what you want to do is changing the page content/behavior you should use page lifecycle events (init, show, hide, destroy) rather than navigator’s.
About the navigator events,
postpushwill already have the page inserted since it’s fired after the push action.
@Fran-Diox Hi Fran :)
I am actually using
/*! onsenui v2.0.0-beta.10-build.2678 - 2016-04-21 */(and as you might now, the issue is a regression bug because it was working as it’s supposed to with a previous beta).
But OK, then, I will build/fetch a more recent nightly and I’ll consider this fixed.
I am listening to the Navigator events because to me it acts like a “frontend controller”: I reset/push on it and then listen to its init/show to manage the page (via a “view” object which takes the page element as its input – using the
But I might reconsider this approach if I can figure out another way to do it, and been able to bind the events on every single page as soon as possible (I have this problem where I have to replace the content of the texts for i18n and right now it works perfectly without any text “flashing”).
Thank for your work, man ;)
P.S. there is a missing test for the “show” event of the navigator… I hope that that event is not going anywhere then :P
For there record, INIT and SHOW seem to still be out of sync with
*! onsenui v2.0.0-beta.10-build.2713 - 2016-04-22 */
@claudioc I tested it again and you were right, the issue was fixed for a different situation. I think now it’s definitely fixed in beta.11 :)