Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery mobile change page

Tags:

I have two column layout for a webpage from the site, http://jquerymobile.com/demos/1.0.1/

Now they have provided provisions to changePage using <a href="#xxx" data-role="button">Sample</a>

But my question is how to programmatically change page using code.

$.mobile.changePage("#xxx"); isn't working for me

like image 714
siva Avatar asked Mar 16 '12 14:03

siva


People also ask

What is jQuery mobile page?

jQuery Mobile is a HTML5-based user interface system designed to make responsive web sites and apps that are accessible on all smartphone, tablet and desktop devices.

Which one of the following methods provided by the jQuery mobile API allows you to perform the page transitions programmatically?

allowSamePageTransition (boolean, default: false) By default, changePage() ignores requests to change to the current active page. Setting this option to true, allows the request to execute.


1 Answers

Here is a real simple example for you: http://jsfiddle.net/shanabus/YjsPD/

$.mobile.changePage("#page2"); 

Documentation: http://api.jquerymobile.com/jQuery.mobile.changePage/

Other examples:

//transition to the "about us" page with a slideup transition $.mobile.changePage( "about/us.html", { transition: "slideup"} );  //transition to the "search results" page, using data from a form with an ID of "search""    $.mobile.changePage( "searchresults.php", {     type: "post",     data: $("form#search").serialize() });  //transition to the "confirm" page with a "pop" transition without tracking it in history    $.mobile.changePage( "../alerts/confirm.html", {     transition: "pop",     reverse: false,     changeHash: false }); 

UPDATE

As Chase Roberts points out in the comments below, this changePage method was deprecated in version 1.4. Here is the documentation for the new pagecontainer change event.

Example:

$.mobile.pageContainer.pagecontainer("change", "#page", { options }); 

This was also addressed on this SO question: How to change page in jQuery mobile (1.4 beta)?

like image 166
shanabus Avatar answered Sep 24 '22 11:09

shanabus