1

i have 2 pages, index.html and about.html

index.html

<!DOCTYPE html> 
<html> 
<head> 
    <title>Page Title</title> 
    ... load jquery and jquery mobile...
</head> 

<body> 
    <div data-role="page" id="index">
    ...content goes here...
        <a href="about.html?id=1"  data-role="button">about</a>
    </div>
</body>
</html>

and about.html has just the page data-role

<div data-role="page" id="about">
...content goes here...
</div>

the problem is that when i click on the link to go to the about page and i try to get the url string, well, it shows me index.html

window.location.toString();

or

$.mobile.activePage.data('url');

both return index.html instead of about.html?id=1

i understand that the about.html gets loaded into the index page, but how to grab that id??

any ideas?

thanks

Gajotres
  • 57,309
  • 16
  • 102
  • 130
Patrioticcow
  • 26,422
  • 75
  • 217
  • 337
  • I don't know about phonegap, but you can do it with DOM. Get all child nodes of "index-id" element, and then get the href-attribute and split it from '?' to get the id. It seems obscure, but it will work. – nsthethunderbolt Jan 31 '13 at 10:03

1 Answers1

0

ChangePage method needs to be used to send parameters from one page to another:

$(document).on('pagebeforeshow', '#index' ,function () {
    var parameters = $(this).data("url").split("?")[1];;
    parameter = parameters.replace("parameter=","");  
    alert(parameter);
});

If you want to find out more take a look at this ARTICLE, to make it transparent it is my personal blog. Or it can be find HERE. Look for a chapter called: Data/Parameters manipulation between page transitions

Community
  • 1
  • 1
Gajotres
  • 57,309
  • 16
  • 102
  • 130