new Dialog()
- Description:
A class for a Dialog box.
An instance of a Dialog can be accessed indirectly by use of
one of the showXxx methods.
- Source:
Example
Show a basic simple OK Dialog box
dialogs.showOk("Here's a nice OK dialog box!");
Methods
buttonJq(name) → {JQuery|null}
- Description:
Return the button DOM for the given name.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | The name of the button. |
Returns:
the Button's jQuery DOM object or null if nothing found.
- Type
- JQuery | null
cancel(handleropt) → {module:dialogs~Dialog}
- Description:
Add a 'cancel' handler to the Dialog or if no handler is specified,
simulate clicking the Dialog's 'cancel' button.
- Source:
- See:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
handler |
function |
<optional> |
if specified, the handler to be invoked |
Returns:
click(name) → {module:dialogs~Dialog}
- Description:
Click one of the Dialog's buttons.
- Source:
Example
Show a Dialog with an OK button and click it 2 seconds later
var dlg = dialogs.showOk("This is an OK Dialog")
setTimeout(function () {
dlg.click("ok")
}, 2000);
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | The name of the Dialog button to click. |
Returns:
close(nameopt, failopt) → {module:dialogs~Dialog}
- Description:
Close the Dialog. This will remove the Dialog box from the screen.
- Source:
Example
Open a Dialog and close it after 2 seconds
var dlg = dialogs.showOk("A notification");
setTimeout(function () {
dlg.close();
}, 2000);
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
name |
String |
<optional> |
The name of the button used to close the dialog box. |
fail |
* |
<optional> |
optional failure reason. If truthy, the dialog's promise |
Returns:
content() → {JQuery}
- Description:
If this dialog has content, return the jQuery DOM wrapper for it.
- Source:
Returns:
The DOM wrapper for the content. This wrapper will
be empty if the dialog is shown with no content.
- Type
- JQuery
disableButton(name) → {module:dialogs~Dialog}
- Description:
Disable a button.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | The name of the button. |
Returns:
enableButton(name) → {module:dialogs~Dialog}
- Description:
Enable a button.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | The name of the button. |
Returns:
header() → {JQuery}
- Description:
If this dialog has a header, return the jQuery DOM wrapper for it.
- Source:
- Since:
- Niagara 4.12
Returns:
The DOM wrapper for the header. This wrapper will
be empty if the dialog is shown with no header.
- Type
- JQuery
hide() → {module:dialogs~Dialog}
- Description:
Hide the Dialog without closing it. The preferred method
to use is close.
- Source:
Example
Hide a dialog box after 2 seconds
dialogs.showYesNo("Meeting alert! Do you want to be reminded in 10 seconds?")
.yes(function (dialog) {
dialog.hide();
setTimeout(function () {
dialog.show();
}, 10000);
return false;
});
Returns:
hideButton(name) → {module:dialogs~Dialog}
- Description:
Hide a button.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | The name of the button. |
Returns:
isClosed() → {Boolean}
- Description:
Return true if the Dialog is closed and removed from the DOM.
- Source:
Returns:
Return true if the Dialog has been closed.
- Type
- Boolean
isHidden() → {Dialog}
- Description:
Return true if the Dialog is hidden.
- Source:
Returns:
Return true if the Dialog has been hidden.
- Type
- Dialog
jq() → {JQuery}
- Description:
Return the internal jQuery wrapped DOM element for the entire Dialog.
- Source:
Returns:
the Dialog's jQuery DOM object.
- Type
- JQuery
no(handleropt) → {module:dialogs~Dialog}
- Description:
Add a 'no' handler to the Dialog or if no handler is specified,
simulate clicking the Dialog's 'no' button. The first argument of the
function callback is the Dialog instance.
- Source:
- See:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
handler |
function |
<optional> |
if specified, the handler to be invoked |
Returns:
ok(handleropt) → {module:dialogs~Dialog}
- Description:
Add a 'ok' handler to the Dialog or if no handler is specified,
simulate clicking the Dialog's 'ok' button.
- Source:
- See:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
handler |
function |
<optional> |
if specified, the handler to be invoked |
Returns:
on(name, handler) → {module:dialogs~Dialog}
- Description:
Add a callback handler for a button via its name. This callback
handler will be invoked when the button is clicked.Any handler function can return a Promise. This
can control when and if the Dialog box closes after the handler
has been invoked. It should be noted that multiple handlers
can be registered on a button.- If the handlers return nothing, the Dialog will be closed after
all the Handlers have been invoked. - If one or more handlers return a Promise, the Dialog
will only close after all the Promises have been resolved. - If one of the Promises is rejected, the Dialog will not close.
- If the handlers return nothing, the Dialog will be closed after
- Source:
- See:
Example
Register a function be to be called when the 'foo' button is clicked.
dialogs.show({
content: "Show some stuff",
buttons: [
{
name: "foo",
handler: function () {
alert("First annoying alert!");
}
}
]
}).on("foo", function () {
alert("This will also be called when foo button is clicked.");
});
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | The name of the button to register the handler on. |
handler |
function | The handler of the function to be |
Returns:
promise() → {Promise}
- Description:
Return a promise for the dialog that will be resolved when the dialog closes.
This is useful when wanting to use dialogs in a promise chain when creating a user interface.
- Source:
Returns:
The promise to be resolved.
- Type
- Promise
show() → {module:dialogs~Dialog}
- Description:
Show the Dialog.
- Source:
Example
Create a blank dialog box and then show it.
dialogs.make("A dialog box with no buttons!")
.show();
Returns:
showButton(name) → {module:dialogs~Dialog}
- Description:
Show a button.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String | The name of the button. |
Returns:
toBack() → {module:dialogs~Dialog}
- Description:
Move the Dialog to the back.
- Source:
Returns:
toFront() → {module:dialogs~Dialog}
- Description:
Move the Dialog to the front.
- Source:
Returns:
yes(handleropt) → {module:dialogs~Dialog}
- Description:
Add a 'yes' handler to the Dialog or if no handler is specified,
simulate clicking the Dialog's 'yes' button.
- Source:
- See:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
handler |
function |
<optional> |
if specified, the handler to be invoked |