ViewController
ViewController is a function that creates widgets, controls their display logic, calls widget methods, and handles events.
Before using a ViewController, you need to register it with CallGear.UI.registerViewController().
registerViewController
This method takes two parameters:
- the ViewController name
- the ViewController function
Allowed ViewController names
sitephonecall_generatoroffline_message_generatorpersonal_form
registerViewController guarantees that the ViewController function is called only after three conditions are met:
- Widget styles are loaded.
- Widget settings are loaded.
- Widget templates are loaded.
Settings and templates are available inside the ViewController function as parameters.
To create widgets inside a ViewController, use CallGear.UI.createWidget().
Example
var SitephoneViewController = function(settings, tpls) {
console.log('The sitephone widget environment is ready');
var sitephone = CallGear.UI.createWidget(...)
}
CallGear.UI.registerViewController('sitephone', SitephoneViewController)
The Sitephone ViewController runs once when the page is loaded. Lead generator ViewControllers run every time the corresponding form is shown.