Page 1 of 1

When returning to a previous screen, how do I load the screen exactly where the user left off earlier?

Posted: Sat Nov 03, 2012 3:27 pm
by Melvin Tan Gim Huat

I have a summary screen that will load 25 items. The user can scroll up and down this summary screen. Clicking any of the items will bring the user to another screen.

Now, when the user navigates back to the summary screen, I need the summary screen to be loaded exactly where the user left off previously.

How do I do that?

Thank you.


When returning to a previous screen, how do I load the screen exactly where the user left off earlier?

Posted: Sat Nov 03, 2012 6:25 pm
by maxkatz

jQuery Mobile might have a feature for that but you can try to add a anchor to the place in page you want to jump when you go back.


When returning to a previous screen, how do I load the screen exactly where the user left off earlier?

Posted: Wed Nov 07, 2012 1:03 pm
by Melvin Tan Gim Huat

Does Tiggzi provide this option?
Otherwise, would you happen to have sample code to share?

Thanks.


When returning to a previous screen, how do I load the screen exactly where the user left off earlier?

Posted: Wed Nov 07, 2012 5:11 pm
by maxkatz

This feature would need to be coded. I don't have any sample code to share.


When returning to a previous screen, how do I load the screen exactly where the user left off earlier?

Posted: Wed Nov 07, 2012 5:54 pm
by Eric5020946

add CLICK event to each item on your list, when user clicks item, update localstorage variable with ID of the item

add new action CUSTOM JS for event PAGE SHOW or LOAD depends on your project structure, in this action set focus to ID stored in localstorage variable, should work


When returning to a previous screen, how do I load the screen exactly where the user left off earlier?

Posted: Thu Nov 08, 2012 12:32 am
by Melvin Tan Gim Huat

Thanks Eric. I understand the concept but am unsure how to implement the part on "set focus to ID stored in localstorage variable".

In Custom JS, how do I implement the above in ""?

Thank you.


When returning to a previous screen, how do I load the screen exactly where the user left off earlier?

Posted: Thu Nov 08, 2012 2:57 pm
by Emmz

Hi !
This will work if your Project is a Multi-page design.
On each of your Buttons add this custom Js on "Click " in Properties Tab
codevar button = $(this).attr('dsid');
localStorage.setItem('lastbutton', button);
Tiggzi.navigateTo('pagebuttonClickToGoTo',{ transition: 'none'});/code

Now add this custom Js to the screen(with the buttons) using "Page Show"
codevar button = localStorage.getItem('lastbutton');
Tiggzi(button).focus();/code

If a single page template design. Use this code on "Page Show" instead..
codevar button = localStorage.getItem('lastbutton');
setTimeout(function() {Tiggzi(button).focus();},500);/code

Now when the user goes to this page it will jump to last clicked button !
Hope it works for you.
Regards.


When returning to a previous screen, how do I load the screen exactly where the user left off earlier?

Posted: Sun Nov 18, 2012 3:58 pm
by Melvin Tan Gim Huat

Hi Neil,

Thanks for the code. I tried the multipage code but it did not work. I'm not sure if it is due to the Tiggzi update bugs (I notice we are interacting in a related thread) or something else that I'm doing wrong.

As I'm going through the logic to debug, I understand your code but don't really understand the line "Tiggzi(button).focus();". This looks like it is part of the Tiggzi API, but when I searched for this on the tiggzi API page, I couldnt find it and hence, am not sure how to use this.

Is there a placeholder in this line of code you provided that I need to change?

Thank you.


When returning to a previous screen, how do I load the screen exactly where the user left off earlier?

Posted: Sun Nov 18, 2012 8:53 pm
by maxkatz

button - is the component name. Tiggzi('id') is a short cut to getting a reference to jQuery Mobile element. You can always use jQuery directly.


When returning to a previous screen, how do I load the screen exactly where the user left off earlier?

Posted: Mon Nov 19, 2012 2:36 pm
by Emmz

button is the variable name I used. Value of "button" is set from local storage.
Local storage button id is set when button is clicked.
I tested this morning on tiggzi chrome and firefox. Works fine.
Maybe add some console.log to see it work? May help to debug.
eg.
code
var button = localStorage.getItem('lastbutton');
console.log(button);
Tiggzi(button).focus();/code

The Important thing is to ensure use use your own screen name where I put "pagebuttonClickToGoTo".