ons

A global object that’s used in Onsen UI.

Methods Summary

Signature Description
isReady() Returns true if Onsen UI is initialized.
isWebView() Returns true if running inside Cordova.
ready(callback) Method used to wait for app initialization. The callback will not be executed until Onsen UI has been completely initialized.
setDefaultDeviceBackButtonListener(listener) Set default handler for device back button.
disableDeviceBackButtonHandler() Disable device back button event handler.
enableDeviceBackButtonHandler() Enable device back button event handler.
enableAutoStatusBarFill() Enable status bar fill feature on iOS7 and above.
disableAutoStatusBarFill() Disable status bar fill feature on iOS7 and above.
disableAnimations() Disable all animations. Could be handy for testing and older devices.
enableAnimations() Enable animations (default).
disableAutoStyling() Disable automatic styling.
enableAutoStyling() Enable automatic styling based on OS (default).
forcePlatformStyling(platform) Refresh styling for the given platform.
createPopover(page, [options]) Create a popover instance from a template.
createDialog(page, [options]) Create a dialog instance from a template.
createAlertDialog(page, [options]) Create a alert dialog instance from a template.
resolveLoadingPlaceholder(page) If no page is defined for the ons-loading-placeholder attribute it will wait for this method being called before loading the page.

Methods

isReady(): Boolean

Returns true if Onsen UI is initialized.

Returns: Will be true if Onsen UI is initialized.

isWebView(): Boolean

Returns true if running inside Cordova.

Returns: Will be true if the app is running in Cordova.

ready(callback)

Method used to wait for app initialization. The callback will not be executed until Onsen UI has been completely initialized.

Parameters
Name Type Description
callback Function Function that executes after Onsen UI has been initialized.

setDefaultDeviceBackButtonListener(listener)

Set default handler for device back button.

Parameters
Name Type Description
listener Function Function that executes when device back button is pressed.

disableDeviceBackButtonHandler()

Disable device back button event handler.

enableDeviceBackButtonHandler()

Enable device back button event handler.

enableAutoStatusBarFill()

Enable status bar fill feature on iOS7 and above.

disableAutoStatusBarFill()

Disable status bar fill feature on iOS7 and above.

disableAnimations()

Disable all animations. Could be handy for testing and older devices.

enableAnimations()

Enable animations (default).

disableAutoStyling()

Disable automatic styling.

enableAutoStyling()

Enable automatic styling based on OS (default).

forcePlatformStyling(platform)

Refresh styling for the given platform.

Parameters
Name Type Description
platform string

createPopover(page, [options]): Promise

Create a popover instance from a template.

Returns: Promise object that resolves to the popover component object.

Parameters
Name Type Description
page String Page name. Can be either an HTML file or an containing a component.
options Object Parameter object.
options.parentScope Object Parent scope of the dialog. Used to bind models and access scope methods from the dialog.

createDialog(page, [options]): Promise

Create a dialog instance from a template.

Returns: Promise object that resolves to the dialog component object.

Parameters
Name Type Description
page String Page name. Can be either an HTML file or an containing a component.
options Object Parameter object.

createAlertDialog(page, [options]): Promise

Create a alert dialog instance from a template.

Returns: Promise object that resolves to the alert dialog component object.

Parameters
Name Type Description
page String Page name. Can be either an HTML file or an containing a component.
options Object Parameter object.

resolveLoadingPlaceholder(page)

If no page is defined for the ons-loading-placeholder attribute it will wait for this method being called before loading the page.

Parameters
Name Type Description
page String Page name. Can be either an HTML file or an element.

Discussion

Need Help?

If you have any questions, use our Community Forum or talk to us via Gitter chat. The Onsen UI team and your peers in the community will work together to help solve your issues.

For bug reports and feature requests use our GitHub Issues page.