2020.2

Table Of Contents
Reacting to, or triggering, widget events
The new COTG plugin introduces custom events for COTG controls. You can trigger and/or
react to them as the user interacts with the Form.
l
Use jQuery’s .on() method to attach an event handler to an element (or set of elements).
Call this function on the $(document).ready event, which is triggered when the Form
is loaded in the app.
l
Use the .trigger() method to trigger an element's event.
The events of all COTG widgets are listed in the Capture OnTheGo API: "Capture OnTheGo
API" on page600.
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
Page 589