1.8

Table Of Contents
The following code appends the contents of the variable html to an element on the Form that
has the ID cameras:
$('#cameras').append(html);.
Initializing the widget
A widget has to be initialized to allow it to be actually used. Widgets that are already present in
a Form at startup are initialized as soon as the Form is loaded in the app. A widget that has
been added to a Form dynamically has to be initialized directly after adding it to the Form;
otherwise the new widget won't respond to actions of the user, even though it is visible in the
app.
Initializing a widget takes just one line of code, in which you select the new widget by its ID and
call the initialization function on it. This code, for example, initializes a new Camera element
that has the ID myCamera:
$(#myCamera).cotgPhotoWidget();
Optionally, while initializing an element, you can make settings for this specific element. These
settings get prevalence over the options already specified in the HTML and over the default
settings specified in the COTG plugin.
The code snippet below initializes a new Camera element (with the ID myCamera) with a number
of settings:
$('#myCamera').cotgPhotoWidget({
quality: 50,
height: 1024,
width: 1024
});
The initialization functions and options of all widgets are listed in the Capture OnTheGo API:
"Capture OnTheGo API" on page453.
To learn how to set the defaults for one kind of elements, see "Changing default settings for
widgets" on page444.
Restoring a widget
When a Form is closed, the app stores the values of input fields to the local repository of the
app, but the values of input fields of dynamically added widgets are not stored.
When you reopen the Form the original input fields and their values are restored. However,
Page 447