Advanced Integration

Script not run

The script must be placed before all other scripts in the <head> tag. In some cases, the script might not run as expected even if it is placed correctly. There are several cases where the script doesn’t execute properly. For instance, when the page is dynamically loaded, the script cannot detect the DOMContentLoaded event or this event isn’t relevant because some elements are loaded with XHR.

To solve this problem, there is the event “DCBProtectRun” which triggers the actions normally associated with the DOMContentLoaded. This event should be fired when the page is loaded. Here is how to trigger the event:

var event = new Event('DCBProtectRun');

Script conflict

Another possible issue encountered during the integration is the script conflicting with other scripts on the page. To solve this , there is a function to call which will prevent this conflict. The function evina_notify takes the click event as a parameter, and the callback function can be implemented by the partner with the other page scripts. See below an example :

if (typeof evina_notify === "function") {
    evina_notify(e, function() {
         //callback event

Warning: to prevent conflict with the default use case,  the targeted_element on the call to API script  needs to be “evina_notify”.