Skip to content

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

  1. sitephone
  2. call_generator
  3. offline_message_generator
  4. personal_form

registerViewController guarantees that the ViewController function is called only after three conditions are met:

  1. Widget styles are loaded.
  2. Widget settings are loaded.
  3. 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.