External XUI event handler code

Example by Rob In der Maur of how to place event handler code for a XUI widget outside the XUI document Last Updated: 2006-07-26

In your code just get hold of the XUI element you want add event handler to, define event handler functionality (what needs to be done when button clicked), set up listener and attach it to the XUI element.

// get handle to ok button by its id; xuidoc is the document containing the XUI var okbtn = xuidoc.getElementById("okButton"); // define what needs to be done when ok button clicked function handleClickEvent(e) { Application.alert("Pressed OK button"); } // set up event handling o = { handleEvent: handleClickEvent }; // set up listener with the handler as parameter var okbtnlistener = Packages.org.w3c.dom.events.EventListener(o); // attach event listener to ok button okbtn.addEventListener("DOMActivate", okbtnlistener, false);