Events
- Use events and listeners to listen and react to them during the various phases of a look up.
Listen for Events
DOTSGlobalAddressComplete.listen(<Event>, <Function (){}>);
Listen for Events Example
DOTSGlobalAddressComplete.listen("populate", function(address, variations) { document.getElementById("LabelJSON").innerText = address.FormattedAddress.toUpperCase(); });
Events Table
Event | Description |
---|---|
load | The control is ready and is now listening to page events. |
show | The control is now on the page. |
hide | The control has been hidden. |
search | The user is searching. You can modify the searchTerm and lastId of the search object (parameter 1) at this stage. |
results | Results have been returned from the find service. You can modify the list of suggestions returned (parameter 1) and access the extended attributes object (parameter 2) including properties such as ContainerCount. |
noresults | No matching results were returned from the find service. |
display | The suggestions have been shown to the user. |
select | The user has selected a suggestion. The chosen suggestion can be accessed (parameter 1). |
prepopulate | The full address has been returned from the retrieve service. The address object (parameter 1) can be accessed and modified before fields are populated, as well as full list of language variations (parameter 2) for the address. |
populate | The address fields have been populated. This is the most common event to listen for, and will allow you to populate your own fields with your own logic using the address object (parameter 1) and the list of address variations (parameter 2). |
country | The country has been changed. The selected country object (parameter 1) with iso2, iso3 and name properties is passed through. |
manual | When the manualEntry option is passed through and the user selects the option to enter their address manually this event will fire. |
error | An error has occured. The error message (parameter 1) is passed through. Typically errors are not shown to the user, but can be handled manually here if needed. |
- With all the dynamically loading pages on most modern websites, it may become necessary to load the control manually in the JavaScript using the following command.
Manual Loading
DOTSGlobalAddressComplete.load();