Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Developer
Posts: 84
Registered: ‎04-22-2013
My Device: BB 10 Dev
My Carrier: Simulator

To pop() or navigateTo(navigationPane.at(0))

Hi all,

I'm a little confuse of whether to use nav.pop() or nav.navigateTo(nav.at(0)).

In my main.qml, I have 3 buttons, which nav to page1.qml, page2.qml and page3.qml respectively.

While in page1, I have a back button which navigates to main.qml, and 2 button which navigates to page2 and page3 respectively, same for other pages.

My problem is

- when i use nav.pop(), main->page1->page2->when i pop it goes to page1 

  but what i want is when user click back, i want it to go to main instead of the previous page.

- when i use nav.navigateTo(nav.at(0), main->page1->page2->when i pop it goes to main 

  but when from main goes to page1 again, whatever data user typed in are still there.

 

so which one should i use, if i want main->push page1-> push page2->click back to navigate to main and remove whatever is on top of the main in the stack?

 

thanks in advance.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: To pop() or navigateTo(navigationPane.at(0))

If you're not going to destroy() the pages when you pop or transition away from them, then it's up to you to also clear/reset the pages back to the right starting conditions when you push them again.

I generally just put a reset() routine in my page, which clears the fields to whatever I want them to have, and I call that when I push(). There are variations on that theme... pick whatever approach seems to make sense to you.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!