Loader Widgetversion added: 1.2
Description: Handles the task of displaying the loading dialog when jQuery Mobile pulls in content via Ajax.
The Loader Widget
The loader widget handles the task of displaying the loading dialog when jQuery Mobile pulls in content via Ajax. It can also be displayed manually for custom loading actions using the $.mobile.loading
helper method (See the global method docs).
Theming
The loader widget uses the jQuery Mobile CSS framework to style its look and feel. If loader specific styling is needed, the following CSS class names can be used for overrides or as keys for the classes
option:
-
ui-loader
: Outermost container for loader widget. Iftextvisible
option is usedui-loader-verbose
class will be added. Additionally iftextonly
option is used thenui-loader-textonly
class will added. In all other cases where text is not presentui-loader-default
class will be added.-
ui-loader-item
: Span element of the loader representing the icon -
ui-loader-header
: Header element of the loader representing the text of the loader.
-
To configure the loading dialog globally the following settings can be defined on its prototype during the mobileinit
event.
1
2
3
4
5
6
|
|
These defaults will only be superseded by the method params object described in the global method docs under $.mobile.loading
.
1
2
3
4
5
6
|
|
Options
classes
|
Specify additional classes to add to the widget's elements. Any of classes specified in the Theming section can be used as keys to override their value. To learn more about this option, check out the learn article about the classes
option.
Initialize the loader with the classes
option specified, changing the theming for the ui-loader
class:
1
2
3
4
5
|
|
Get or set a property of the classes
option, after initialization, here reading and changing the theming for the ui-loader
class:
1
2
3
4
5
|
|
defaults
false
true
indicates that other widgets options have default values and causes jQuery Mobile's widget autoenhancement code to omit the step where it retrieves option values from data attributes. This can improve startup time.
This option is also exposed as a data attribute: data-defaults="true"
.
Initialize the loader with the defaults
option specified:
1
2
3
|
|
Get or set the defaults
option, after initialization:
1
2
3
4
5
|
|
disabled
false
true
.
This option is also exposed as a data attribute: data-disabled="true"
.
Initialize the loader with the disabled
option specified:
1
2
3
|
|
Get or set the disabled
option, after initialization:
1
2
3
4
5
|
|
html
""
Initialize the loader with the html
option specified:
1
2
3
|
|
Get or set the html
option, after initialization:
1
2
3
4
5
|
|
text
loading
Initialize the loader with the text
option specified:
1
2
3
|
|
Get or set the text
option, after initialization:
1
2
3
4
5
|
|
textVisible
false
Initialize the loader with the textVisible
option specified:
1
2
3
|
|
Get or set the textVisible
option, after initialization:
1
2
3
4
5
|
|
textonly
false
Initialize the loader with the textonly
option specified:
1
2
3
|
|
Get or set the textonly
option, after initialization:
1
2
3
4
5
|
|
theme
null, inherited from parent
Possible values: swatch letter (a-z).
This option is also exposed as a data attribute: data-theme="b"
.
Initialize the loader with the theme
option specified:
1
2
3
|
|
Get or set the theme
option, after initialization:
1
2
3
4
5
|
|
Methods
checkLoaderPosition()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the checkLoaderPosition method:
1
|
|
fakeFixLoader()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the fakeFixLoader method:
1
|
|
hide()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the hide method:
1
|
|
loading()Returns: jQuery (plugin only)
$.mobile.loader
prototype options as described in the widget docs or can be controlled via a params object.
- This method does not accept any arguments.
Invoke the loading method:
1
|
|
resetHtml()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the resetHtml method:
1
|
|
show()Returns: jQuery (plugin only)
- This method does not accept any arguments.
Invoke the show method:
1
|
|
Events
create( event, ui )Type: loadingcreate
Note: The ui
object is empty but included for consistency with other events.
Initialize the loader with the create callback specified:
1
2
3
|
|
Bind an event listener to the loadingcreate event:
1
|
|
Example:
Loader Examples
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
|