Widget Implement

Action functions

function onload()

Function is called by system when a template and its corresponding javascript actions load into the system. It is called only once at the template/action loading time. Please make sure this function is called only once at first use or load. If you need some initialization per instance (widget) or per page (manually call showWidget), use init() instead.

function init(context)

Function is called by system when widget load into the system. Widgets can use the same template/action with different context. For each context, the init() will be called once. If you want to call showWidget() directly, the init will also be called inside showWidget function().

function destroy(context)

Function is called by system when system unload the widget.

function getInfo(context)

Function is used for analysis purpose. It defines several usage model to collect the pre-defined information. The the system use the type (the key) to identify the schema of the returned array. 1. product (general product, restaurant orders, etc) Widget will return array of product objects. Each object contains name, count and price. Example of returned array [{product:”beef noodle”, count:5, price:50}, {name:”pork noodle”, count:15, price:35}] Here “product” is the type, so the system know it is product schema.