Applies to:
- Winshuttle Foundation
jQuery functions
JavaScript reference guides
In addition to the full built-in jQuery and jQuery UI functionality, the following helper functions can be used within Composer rules.
Click a function below to view more information about it.
- jQuery.alert(message,title,callback)
- jQuery.confirm (message,title,callback,noCallback, yesLabel, noLabel, cancelLabel)
- jQuery.prompt(message,title,initialValue, validateCallback, okCallback)
- jQuery.promptTextArea(message,title,initialValue, validateCallback, okCallback)
- jQuery.choice(message,title,values,okCallback)
- jQuery.choiceTree(message,title,values,okCallback)
jQuery.alert(message,title,callback)
Presents a jQuery modal dialog box.
Parameters
- message – Message to display in the main message box
- title – (optional) Title of the message box (default is ‘Error’)
- callback – (optional) Function to invoke after the user clicks OK.
Example
jQuery.alert('The format of this field in incorrect', 'Format Error');
jQuery.choice(message,title,values,okCallback)
Presents a jQuery modal dialog box with a drop-down list of values to choose from.
Parameters
- message – Message to display in the main message box
- title – Title of the message box
- values – Array of string values to insert into drop down list
- okCallback – (optional) Function to invoke after the user clicks OK
Example
jQuery.choice('Choose a size', 'Choice', ['Small', 'Medium', 'Large'],
function(value) {
$form.setValue('/my:myFields/my:size', value);
});
jQuery.choiceTree(message,title,values,okCallback)
Presents a jQuery modal dialog box with a tree control of values to choose from.
Parameters
- message – Message to display in the main message box
- title – Title of the message box
- values – Array of dynatree Node values to insert into tree control (refer to dynatree documentation for details)
- okCallback – (optional) Function to invoke after the user clicks OK
Example
jQuery.choiceTree('Please choose an item', 'Tree Choice',
[ {
title: 'node 1', key: 'node1', isFolder: true,
children: [ {title: 'node 1.1', key: 'node1_1', isFolder: false},
{title: 'node 1.2', key: 'node1_2', isFolder: false},
{title: 'node 1.3', key: 'node1_3', isFolder: false}
]
},
{
title: 'node 2', key: 'node1', isFolder: true,
children: [ {title: 'node 2.1', key: 'node2_1', isFolder: false},
{title: 'node 2.2', key: 'node2_2', isFolder: false},
{title: 'node 2.3', key: 'node2_3', isFolder: false}
]
}], function(selectedNode) {
jQuery.alert('You chose: '+ selectedNode.data.key);
});
jQuery.confirm (message,title,callback,noCallback, yesLabel, noLabel, cancelLabel)
Presents a jQuery modal dialog box with Yes, No and Cancel buttons.
Parameters
- message – Message to display in the main message box
- title – (optional) Title of the message box (default is ‘Confirmation)
- callback – (optional) Function to invoke after the user clicks Yes.
- noCallback – (optional) Function to invoke after the user clicks No.
- yesLabel – (optional) text of the Yes button (default is Yes)
- noLabel – (optional) text of the No button (default is No)
- cancelLabel – (optional) text of the Cancel button (default is Cancel)
Example
jQuery.confirm('Are you sure you want to do that?',
'Confirm Creation',
function() {
$form.executeWebService('createSomethingInSAP');
});
jQuery.prompt (message,title,initialValue, validateCallback, okCallback)
Presents a jQuery modal dialog box with a text box for user input.
Parameters
- message – Message to display in the main message box
- title – Title of the message box
- initialValue – (optional) Initial value to insert into the text box
- validateCallback – (optional) Function to invoke for validation of input. Function should return true for valid input and false for invalid input (use ‘null’ for no validation)
- okCallback – (optional) Function to invoke after the user clicks OK and the input is valid.
Example
jQuery.prompt('Please enter a number between 1 and 10',
'Enter a Number',
'',
function(value) {
if ( typeof value === 'number' && value % 1 == 0) {
if (value>=1 && value<=10) {
return true;
} else {
jQuery.alert('Value must be >= 1 or <= 10');
}
} else {
jQuery.alert('Enter an integer please');
}
return false;
},
function(value) { $form.setValue('/my:myFields/my:field_1', value); });
jQuery.promptTextArea(message,title,initialValue, validateCallback, okCallback)
Presents a jQuery modal dialog box with a text area (multi-line input field) for user input.
Parameters
- message – Message to display in the main message box
- title – Title of the message boxinitialValue – (optional) Initial value to insert into the text box
- validateCallback – (optional) Function to invoke for validation of input. Function should return true for valid input and false for invalid input (use ‘null’ for no validation)
- okCallback – (optional) Function to invoke after the user clicks OK and the input is valid.
Example
jQuery.promptTextArea('Please enter some text', 'Prompt', '', null,
function(value) {
$form.setValue('/my:myFields/my:bigTextField', value);
});