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

Web and WebWorks Development

Reply
Developer
bnolan001
Posts: 131
Registered: ‎02-19-2011
My Device: Bold 9930 and PlayBook
Accepted Solution

BB10 popScreen resets form data

I'm using bbui.js and testing in Ripple 0.9.10 I'm new to bbui.js so I'm learning as I go.

 

Here is my issue.  I have an application that uses multiple screens.  From the main screen I push a screen on top that lets the user put in some data.  If the user needs more information they can navigate to another screen that is pushed on top.  We now have the main screen, a second screen for input, and a third screen.  From that third screen the user gets what they need, pops the screen and completes their input on the second screen.  Problem is, when the third screen is popped, any input the user put in the second screen prior to navigating to the third screen is gone.  Now I don't know if this is expected behavior or a bug.  If it is expected behavior is there a typical pattern people use to keep the user input on a screen when the user navigates to other screens?

"Not to know what happened before you were born is to be forever a child." Marcus Tullius Cicero
Developer
The_Anomaly
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: BB10 popScreen resets form data

I think its expected behaviour.  popScreen actually removes the screen from the DOM, making the app lighter on memory.  pushscreen does the opposite - it inserts the screen when called.  Its a good way to work and a plus for BB development.

 

That being said, you can create a var in your main index.html that you could populate on your third screen.

 

For example I have a similar situation, except, I'm getting gps coords on the third screen.  I then set the variable gps_coords = ... <- insert coords here.  Which has been declared on the index.html.  When you popscreen and go back to the second screen the var gps_coords has data and can be used on your second screen.  Does that make sense?  I can supply sample code.

If it helped you, click like. :smileyhappy:
Developer
bnolan001
Posts: 131
Registered: ‎02-19-2011
My Device: Bold 9930 and PlayBook

Re: BB10 popScreen resets form data

Yep that makes sense.  I take it that you then use the ondomready callback to then go through and update your fields when the previous screen is popped off the stack?

"Not to know what happened before you were born is to be forever a child." Marcus Tullius Cicero
Developer
The_Anomaly
Posts: 322
Registered: ‎08-06-2012
My Device: Dev Alpha / Playbook / Curve 9300

Re: BB10 popScreen resets form data

[ Edited ]

Not even necessary... check out sample code of the start of my index.html:

 

<html>
<head>
<meta name="viewport" content="initial-scale=1.0,width=device-width,user-scalable=no,target-densitydpi=device-dpi" />
<link  rel="stylesheet" type="text/css" href="bbui-0.9.4.css" />
<link rel="stylesheet" href="leaflet.css" />
<script type="text/javascript" src="leaflet.js"></script>
<script type="text/javascript" src="bbui-0.9.4.js"></script>
<script type="text/javascript">

var fs_id = '';
var sp_id = '';
var rv_id = '';
var use_i = '';
var gps_c;

bb.init({
	bb10ActionBarDark: true,
	bb10ControlsDark: true,
	bb10ForPlayBook: true,
	ondomready: function (element, id) {
	if (id == "profile") {
		doRecallProfile();
    }

The vars at the top get set on the third page in some piece of code:

 

fs_id = 'my settings here';

 ... When you push a screen or go back to your previous screen your javascript for that screen can run a check like:

 

	if (fs_id != '') {
		var itemId = fs_id;
	} else {
		var itemId = 'fs_' + newDate.getTime();
	}

 for example...  Only thing is, I'm not sure how bbui will pick up that this var has changed if you going from screen 3 -> 2 (which in theory is still loaded).  However it has worked for me up till now.  

 

Maybe this is where the ondomready kicks in yes.

 

If it helped you, click like. :smileyhappy: