$.mobile.toast Class
A jQuery Mobile Android-like Toast Plugin.
Constructor
$.mobile.toast
()
chainable
Example:
$.mobile.toast({ message: 'Live long and prosper!' });
Item Index
Methods
Attributes
Methods
_addToPage
()
private
Add toast to page
_beforeEnd
()
private
Called before end and handle close animation. Trigger "beforeClose" event.
_create
()
private
Constructor method, called automaticly
_destroy
()
private
Remove toast from page
_end
()
private
Destroy toast and trigger "afterclose" event.
_getToastCoordinates
()
Object
private
Calculates top, left coordinates to postion toast
Returns:
Position object
_getWindowCoordinates
()
Object
private
Get position an size of page
Returns:
Position/size object
_parseDurationOption
()
Number
private
Parse function for "duration" option
Returns:
Duration in ms
_parseOptions
()
private
Call parse functions for options
_renderText
()
Object
private
Render text method, render and style message in paragraph
Returns:
jQuery fragment
_renderToast
()
Object
private
Render toast method, render and style paragraph in container
Returns:
jQuery fragment
_setOption
-
key
-
value
Called from the _setOptions() method for each individual option. Widget state should be updated based on changes.
Parameters:
-
key
StringThe name of the option to set.
-
value
ObjectA value to set for the option.
_setOptions
()
private
Called whenever the option() method is called, regardless of the form in which the option() method was called. Overriding this is useful if you can defer processor-intensive changes for multiple option changes.
open
()
protected
Open method, open toast and auto-close it after duration
reposition
()
protected
Reposition method, position toast during initialisation and later.
Properties
options
Object
Options of this widget
version
String
Version of the widget
Attributes
classOnClose
String
Optional class to overwrite styling of toast on close.
Default: ""
Example:
$.mobile.toast({
message: 'Live long and prosper',
classOnClose: 'pomegranate'
});
// Change default value
$.mobile.toast.prototype.options.classOnClose = 'pomegranate';
classOnOpen
String
Optional class to overwrite styling of toast on open.
Default: ""
Example:
$.mobile.toast({
message: 'Live long and prosper',
classOnOpen: 'pomegranate'
});
// Change default value
$.mobile.toast.prototype.options.classOnOpen = 'pomegranate';
duration
Number or String
Duration of message show to the user. Possible values: "short", "long" number in milliseconds.
Default: 2000
Example:
$.mobile.toast({
message: 'Live long and prosper',
duration: 2000
});
// Change default value
$.mobile.toast.prototype.options.duration = 2000;
Events
afterclose
Function
After close callback
Example:
$.mobile.toast({
message: 'Live long and prosper!',
afterclose: function( event, ui ){
console.log('afterclose');
}
});
$.mobile.toast.on('toastafterclose', function( event, ui ){});
afteropen
Function
After open callback
Example:
$.mobile.toast({
message: 'Live long and prosper!',
afteropen: function( event, ui ){
console.log('afteropen');
}
});
$.mobile.toast.on('toastafteropen', function( event, ui ){});
beforeclose
Function
Before close callback
Example:
$.mobile.toast({
message: 'Live long and prosper!',
beforeclose: function( event, ui ){
console.log('beforeclose');
}
});
$.mobile.toast.on('toastbeforeclose', function( event, ui ){});
beforeposition
Function
Before position callback
Example:
$.mobile.toast({
message: 'Live long and prosper!',
beforeposition: function( event, ui ){
console.log('beforeposition');
}
});
$.mobile.toast.on('toastbeforeposition', function( event, ui ){});
create
Create callback
Example:
$.mobile.toast({
message: 'Live long and prosper!',
create: function( event, ui ){
console.log('create');
}
});
$.mobile.toast.on('toastcreate', function( event, ui ){});