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
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.
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.
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)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With