Page Widgetversion added: 1.0
Description: Primary unit of content.
The page widget is responsible for managing a single item in jQuery Mobile's page-based architecture. It is designed to support either single page widgets within a HTML document, or multiple local internal linked page widgets within a HTML document.
The goal of this model is to allow developers to create websites using best practices — where ordinary links will "just work" without any special configuration — while creating a rich, native-like experience that can't be achieved with standard HTTP requests.
Caveat: Documents containing multiple pages cause Internet Explorer 7 to exhibit incorrect behavior when its "Back" button is pressed. In particular, if the user navigates between several of the pages internal to the document that has been loaded and then clicks the "Back" button to return to the start page, there will be occasions when clicking the "Back" button does not cause a return to the previous page. However, clicking the "Back" button enough times will eventually return the user through the performed navigation sequence back to the start page.
Thus, if Internet Explorer 7 represents a significant proportion of the targeted user base, we recommended that pages be organized as individual HTML documents containing single page widgets, rather than as a single HTML document containing multiple internal pages.
Options
domCacheType: Boolean
false
Sets whether to keep the page in the DOM after the user has navigated away from it.
This option is also exposed as a data attribute: data-dom-cache="true"
.
Initialize the page with the domCache
option specified:
1
|
|
Get or set the domCache
option, after initialization:
1
2
3
4
5
|
|
keepNativeDefaultType: String
:jqmData(role='none'), :jqmData(role='nojs')
The value of this option is a selector that will be used to prevent elements matching it from being enhanced.
This option is also exposed as a data attribute: data-keep-native-default=".do-not-enhance"
.
Initialize the page with the keepNativeDefault
option specified:
1
|
|
Get or set the keepNativeDefault
option, after initialization:
1
2
3
4
5
|
|
themeType: String
c
Sets the swatch that will be used to draw the page.
This option is also exposed as a data attribute: data-theme="a"
.
Initialize the page with the theme
option specified:
1
|
|
Get or set the theme
option, after initialization:
1
2
3
4
5
|
|
Methods
keepNativeSelector()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the keepNativeSelector method:
1
|
|
removeContainerBackground()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the removeContainerBackground method:
1
|
|
setContainerBackground( theme )Returns: jQuery (plugin only)
-
themeType: String
Invoke the setContainerBackground method:
1
|
|
Events
beforecreate( event )Type: pagebeforecreate
Triggered before a page is created. If one of the handlers returns false, the page is not created.
-
eventType: Event
Note: The ui
object is empty but included for consistency with other events.
Initialize the page with the beforecreate callback specified:
1
2
3
|
|
Bind an event listener to the pagebeforecreate event:
1
|
|
create( event )Type: pagecreate
Triggered after a page has been created. jQuery Mobile will use this event to apply its enhancements to the page.
-
eventType: Event
Note: The ui
object is empty but included for consistency with other events.
Initialize the page with the create callback specified:
1
2
3
|
|
Bind an event listener to the pagecreate event:
1
|
|
Example:
A basic example of a page.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
|