1.8

Table Of Contents
Examples
The sample below attaches an event handler to the "set" event of a Signature element. Once
the signature is set (that is, after the user has clicked the Done button), the event handler
triggers events of the Date and Geolocation elements. The Date element is set with today's
date and the Geolocation element is updated with the current location.
$(document).ready(function() {
$('#signature').on("set.cotg", function() {
$("#date").trigger("set.cotg", new Date()); // set current date
$("#geolocation").trigger("update.cotg"); // get current
geolocation
});
});
The following example invokes the Date dialog when the user clicks a button.
$(document).ready(function() {
$('#my-datepicker-button').on('click', function() {
$('#date1').trigger("show-date-picker.cotg", new Date("2018-01-
01"));
});
});
Dynamically adding COTG widgets
Capture OnTheGo (COTG) widgets can be added to a Form dynamically, via jQuery. For
example: a new Camera element could be added when the user clicks an Add button. This
topic explains how to implement this. It is assumed that you have a basic understanding of
HTML forms, CSS, JavaScript, and jQuery.
Prerequisites
Before you can start writing code that adds a widget in response to an action of the user, you
need the following:
l Some element on the Form to trigger the creation of the widget. This could be anything
that responds to an action of the user; a button or link, for example. Make sure that this
element has an ID.
l A Form element to which the new widget can be added; a <div> for example. Again, make
sure to give this element an ID.
Page 445