0

In my application I navigate from one pages to another using jquery mobile. Now my problem is that, currently I am on third page an I want to know the id of parent page(or first page). Is this possible in jquery mobile or javascript. If yes, then how I perform this.

Thanks in advance. Any help is appreciated.

yenu
  • 5
  • 5
  • search for localStorage, it stores values on the browser, you can use it and renew the value everytime you change the page. http://coding.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/ – Toping Feb 08 '13 at 11:46
  • there is `history` DOM object, you able to use to navigate – Sugar Feb 08 '13 at 12:06
  • try this [Link][1].For getting previous page id. [1]: http://stackoverflow.com/questions/7628694/jquery-mobile-getting-id-of-previous-page – shankar.parshimoni Feb 08 '13 at 12:11

1 Answers1

0

This should be used to get an id of a previous page.

$(document).on('pagebeforeshow', '#second', function(e, data){       
    alert(data.prevPage.attr('id'));
});

jsFiddle example: http://jsfiddle.net/Gajotres/nPeLf/

More about this solution and few others (with examples) can be found in my ARTICLE, to be transparent it is my personal blog. Or you can find it HERE. In both cases search for the chapter: Data/Parameters manipulation between page transitions.

Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130
  • But I want to id of first page from current page is called and according to this, I want to call a method using if-else. – yenu Feb 08 '13 at 11:55
  • you would need to store it by yourself, jQM only remembers urlHistory and it will not store page id's. Use methods found in my posted link and store your id history in some JSON object. – Gajotres Feb 08 '13 at 12:24
  • localstorage is your best bet because it is a persistent storage. – Gajotres Feb 08 '13 at 12:26