1.6

Table Of Contents
when all the COTG widgets have saved their state. The second event gets fired when the
COTG widgets have restored their state.
Example
The following JavaScript code saves the value "test: " when the Form is saved. On reopening
the Form, the code gets the restored URL of the COTG Image element, appends it to the saved
"test: " string and puts the result in a <p> element at the top of the form.
window.addEventListener("olcotgsavestate", function(event) {
event.detail.state["mywidget"] = "test: ";
}, false);
window.addEventListener("olcotgrestorestate", function(event) {
var value = event.detail.state["mywidget"];
value = value + $("#camera1 img").attr("src");
$("form p").html(value);
}, false);
With jQuery you must use event.originalEvent in the handler functions, for example:
$(window).on("olcotgsavestate", function(event) {
event.originalEvent.detail.state["mywidget"] = "test: ";
});
Note that you should register for the event directly in the JavaScript file (a separate JavaScript
file, preferably, not cotg-1.2.1.js). You should not do this on the document ready event.
The order of JavaScript file includes in the template does not matter.
Testing the template
A Capture OnTheGo (COTG) template will be used to create a form that can be downloaded,
filled out and submitted using the COTG app. Before starting to actually use the template, you
will want to make sure that it produces a form that looks good and functions as expected. How
to preview the form, how to submit data and how to preview the submitted data is described in
another topic: "Testing a Capture OnTheGo Template" on page379.
Sending the template to the Workflow tool
After testing the template (see "Testing a Capture OnTheGo Template" on page379) the
template must be sent to the Workflow module. Templates sent to the Workflow module can be
Page 361