new Widget(attributes)

Creates a Widget instance.

The new widget must be stored inside a container (i.e. in an Obj or another Widget) before it can be used.

A widget can be stored inside a container by adding it to a widgetlist attribute using Obj#update or Widget#update.

Params

  • attributes (Object) - The attributes of the new widget. The _objClass must be provided.

Example

Creating a Page Obj object and a widget and placing the latter into the body widgetlist of the page.

Copy
page = Scrivito.getClass("Page").create({});
widget = new (Scrivito.getClass("TextWidget"))({text: 'Hello World'});
page.update({body: [widget]});