How to add custom logic to existing Nuxeo Web UI buttons
The first problem is that there are already some functions attached to the click event of the button.
Adding a new event, does not guarantee it will run first.
removeEventListener() does not help, as we don’t have access to the function pointer to be removed.
cloneNode() you can clone your button, hide it and replace it with the cloneButton adding a custom logic in the cloneButton click event function, but the original button is not static, it has fields and styles updated by Polymer (and we need them).
const node = document.getElementById("demo"); const clone = node.cloneNode(true); document.body.appendChild(clone);