Jamil
Jamil

Reputation: 671

jQuery Mobile, navigation with query strings

In my jQuery Mobile project, I have a page that shows a slide's content. The content is dependent of the query string.

On opening of the first slide by visiting #slidePage?sec=0&page=0 -> It works

On the same slide page I have a link for #slidePage?sec=0&page=1 ( the second page). --> this link doesn't work

Seems that the browser or jQuery is convinced that it is the same page and do not navigate .

What can I do ?

I tried to disable ajax but that didn't work.

Upvotes: 2

Views: 3843

Answers (3)

Phill Healey
Phill Healey

Reputation: 3180

@Cameron Askew has just released a brilliant JQuery (Mobile) plugin that enables you to send QueryString parameters between pages:

https://github.com/CameronAskew/jquery.mobile.paramsHandler

Upvotes: 2

DalSoft
DalSoft

Reputation: 11097

You can do this just with jquery mobile. On pagebeforeshow simply read the data-url attribute that jquery mobile adds to the page. Then just add the code to do what you need to do with the querystring.

This will only work with Ajax navigation rather than multi-page.

<a href="your-page.html?id=1" data-role="button">Show page "two" querystring id=1</a>

<script type="text/javascript">
$('#your-page-id-here').on('pagebeforeshow',function(){

    console.log($(this).data("url"))

});
</script>

Upvotes: 0

Jamil
Jamil

Reputation: 671

Query strings (to internal pages) are not supported by jQuery mobile.

There are a number of jQuery mobile plugins that could be useful to enable this feature.

See: http://jquerymobile.com/demos/1.0.1/docs/pages/page-scripting.html

Upvotes: 1

Related Questions