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
New Developer
Posts: 7
Registered: ‎02-26-2011
My Device: Blackberry Bold 9780
My Carrier: telkomsel

Requesting for Tips on WebWorks Back Button One Page

Hi everyone,

I am developing a BB app using webworks. This is a one-page app in which all other modifications on the layouts are done via DOM.

I wanted to mimic the back button so that it will go back to the last requested layout. So, what I did is that whenever there's a new content, the program will save the current html content in the #content div into a js array using push(). If a back button is pressed, it will then pop() the saved content from the js array and insert them into the #content div.

This actually works but the loading seems to take some time. It might be that it needs to be redrawn.

Thus, I wonder if there's a faster way to actually mimic the actual back button on an app that uses ajax interaction.

Thank you!
New Contributor
Posts: 5
Registered: ‎03-29-2011
My Device: BlackBerry Torch 9800
My Carrier: AT&T

Re: Requesting for Tips on WebWorks Back Button One Page

We have a similar application that is one page with DOM changes.  Many of the reasons for this involve HTML5, etc.  We have a queue that we push/pop the javascript function call that generates the page. 

 

We registered the back button command to go to a specific javascript function:

if (typeof(blackberry) != "undefined") {blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK,rimBackButton);}

 

Then when the back button is pressed, we pop the stack and call eval() to execute the function.

 

Hope this helps!

Highlighted
New Developer
Posts: 7
Registered: ‎02-26-2011
My Device: Blackberry Bold 9780
My Carrier: telkomsel

Re: Requesting for Tips on WebWorks Back Button One Page

Mbushman,

 

Thank you for your reply! Smiley Happy

 

Mbushman, I am wondering when you pop the stack and eval(), do you actually modify the current DOM (insert the old stuffs back) or do you actually do something else?

 

As for us, we basically save the HTML codes inside JS, then when the back button is pressed, the program will just take back the old code and dump it into HTML. This actually causes a re-draw that makes the loading of the old page pretty slow.

 

Thank you for sharing!