XUI event handlers in separate functions

Example code by Clay Helberg Last Updated: 2006-06-18

Another approach is to use function calls, and define the functions in the WindowLoad script, something like this:

  buttonClicked;   buttonClicked;   buttonClicked;  // define functions used in dialog function buttonClicked { id = Application.event.target.getAttribute("label"); Application.alert("Button click on " + id); }

It might even work to call functions that are defined in other script files, as long as those files get loaded before the XUI dialog calls the function (e.g. in doctype.js or instance.js)--but I don't know that for sure. A quick experiment should reveal the answer, though.

Also, one other thing to keep in mind about using event listeners as Rob describes below: the syntax for defining and attaching event listeners differs slightly between Rhino Javascript and MS JScript. See the Epic programmer's guide for details of how to define event listeners for each javascript engine.