Chapter 5. jQuery Mobile API
In addition to all of the predefined elements and interactions, jQuery Mobile exposes an extensive API consisting of methods, events, and configuration options. These give you finer control over jQuery Mobile elements and interactions.
jQuery Mobile Methods
jQuery Mobile provides a set of basic view-level methods. These methods enable you to manually handle pages and scrolling.
changePage
The changePage
method is used to manually change
views within a jQuery Mobile application. This is
useful for programmatically changing pages in situations other than when the user simply
taps on a link in the application.
As discussed in Chapter 2, jQuery Mobile
updates the location.hash
object as the user moves
through pages in the application, allowing the framework to use the browser’s native
history capabilities to store the navigation information. The changePage method gives you
an easy way to maintain that flexibility without having to manage the URLs
yourself.
changePage(
to
,
transition
,
back
,
changeHash
)
to: one of the following:
a simple string denoting either an element ID or a filename
an array of two elements, with the first being a simple string denoting the element ID or filename of the page to transition from, and the second being a simple string denoting the page to transition to
an object with the following properties:
url: the url string of the desired page
type: the HTTP verb (“GET” or “POST”)
data: serialized parameters to send to the url
transition: the ...
Get jQuery Mobile now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.