2021.2

Table Of Contents
page567) and specify the desired default settings in that file like this:
$.fn.widget.defaults.setting = value;
Make sure to include your JavaScript file in the Web context or in the Web section that contains
the COTG Form (see "Including a JavaScript file in a Web context" on page569).
All available settings are listed in the Capture OnTheGo API: "Capture OnTheGo API" on
page622.
Example
The following code sets the default timeout and accuracy for Geolocation objects. and the
default maximum height and width for Camera widgets.
$.fn.cotgGeolocation.defaults.timeout = 6000; // 6 secs
$.fn.cotgGeolocation.defaults.enableHighAccuracy = true;
$.fn.cotgPhotoWidget.defaults.width = 1024;
$.fn.cotgPhotoWidget.defaults.height = 768;
$.fn.cotgPhotoWidget.defaults.quality = 60;
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622.
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
Page 610