Events
The on and un methods are used for responding to server commands or interacting with a page widget.
These methods subscribe to and unsubscribe from widget events.
An example of interaction with events:
var onRender = function () {
sitephone.show();
};
// subscribe to an event
sitephone.on('render', onRender);
// unsubscribe from an event
sitephone.un('render', onRender);
Cancelling method calls via before{methodName} events
There are events that precede method calls:
- beforeshow
- beforehide
- beforedestroy
- beforerender
If the handler of one of these events explicitly returns false, the corresponding method will not be called.
Example:
sitephone.on('beforeshow', function () {
return !customWidget.isVisible();
});
sitephone.show();
In this example, the show method will not be called if the handler returns false.