Javascript Actions


Javascript Actions enable you to call Action Javascript from places in the UX Component where Action Javascript isn't directly available.

Action Javascript can be added to control events through their event editor. However, Client-Side Events for the UX component don't have an Action Javascript editor mode. They have to be defined with javascript. Javascript Actions let you define Action Javascript events that can be called anywhere in a UX component using the {dialog.object}.runAction() method.

In the UX component properties, there is a property called "Javascript Actions". Click the button to open the Javascript Actions window. Creating a Javascript Action is a two-fold process. First, you must create a Javascript Action. The action name must be unique. The name is the value you will pass to {dialog.object}.runAction() to call your Javascript Action.


After the Javascript Action is created, you can then select the Javascript Action and edit it by clicking the Edit Action button. Editing the action opens the Unbound Event Editor. This editor is the same editor you find when editing the click or onKeyPress event for a control. Like control events, you can add any number of actions to your Javascript Action.


A small red or green dot appears next to the action name in the Javascript Actions window. This visual feedback indicates whether or not a Javascript Action has been defined. If nothing has been defined for the action, it will be red. If an action calls any Action Javascript or has javascript or server-side Xbasic, the dot will be green.


To call a Javascript Action, use {dialog.object}.runAction(). You can type the function call out yourself, or click on "Click to see the Javascript code to invoke this action" link in the Javascript Actions window:


{dialog.object}.runAction() takes a second, optional parameter. If an Action Javascript requires information about the object that runs the action, you need to pass in that object to the {dialog.object}.runAction() method. The "Open a Help Window" is an example of an Action Javascript that may require an object. The Window Position's can be relative to the control that invoked the action. Since Javascript Actions are not bound to any control, the object referenced by your Javascript Action doesn't have to be the one the user clicked.

var ele = {dialog.object}.getPointer('MY_CONTROL');

Javascript Actions can be called anywhere, including Client-Side Events, Javascript Functions, or control events. They can also be exported and imported across UX components using the "Copy/paste actions" link.