Module: ko/dialogs

Easily spawn dialogs without fiddling in their markup

Methods


require("ko/dialogs").alert(message [, opts])

Show an alert message

All opts can be left blank or specified as null to get a default value. "title" is the dialog title.

Parameters:
Name Type Argument Description
message String

The message

opts Object <optional>

Optional object with options

Properties
Name Type Argument Description
title string <optional>

dialog title


require("ko/dialogs").confirm(message [, opts])

Ask the user for confirmation

Parameters:
Name Type Argument Description
message string

The message

opts object <optional>

Optional object with options

Properties
Name Type Argument Description
response string <optional>

The default response. This button is shown as the default. Must be one of "Yes" or "No". If left empty or null the default response is "Yes".

text string <optional>

Allows you to specify a string of text that will be display in a non-edittable selectable text box. If "text" is null or no specified then this textbox will no be shown.

title string <optional>

dialog title

doNotAskPref string <optional>

prefname to use that stores whether the user chose not to give this prompt again. If no prefname is given the prompt will always be shown.

yes string <optional>

override the label for the yes button (defaults to Ok)

no string <optional>

override the label for the no button (defaults to Cancel)

Returns:
Type
Boolean

require("ko/dialogs").filepicker(message, callback [, opts])

Pick a file or Folder from the file system.

Parameters:
Name Type Argument Description
message String

The message

callback function

function to handle

opts Object <optional>

Optional object with options

Properties
Name Type Argument Default Description
message string <optional>

The message

path string <optional>

Location to open file picker at

type string <optional>
file|folder

Type of file system item we're looking for


require("ko/dialogs").open(message [, opts])

Show the user some prompt and request one of a number of responses.

Parameters:
Name Type Argument Description
message String

The message to be displayed to the user

opts object <optional>

Optional object with options

Properties
Name Type Argument Description
prompt string <optional>

Message to show as the prompt

buttons string | array <optional>

Either a list of strings, each a label of a button to show, or a list of array items [label, accesskey, tooltiptext], where accesskey and tooltiptext are both optional. Currently this is limited to three buttons, plus an optional "Cancel" button. For example to mimic (mostly) ko.dialogs.yesNo use ["Yes", "No"] and to mimic ko.dialogs.yesNoCancel use ["Yes", "No", "Cancel"]. Note that the Cancel button must always be last.

response string <optional>

The default response. This button is shown as the default. Must be one of "Yes" or "No". If left empty or null the default response is "Yes".

text string <optional>

Allows you to specify a string of text that will be display in a non-edittable selectable text box. If "text" is null or no specified then this textbox will no be shown.

title string <optional>

dialog title

doNotAskPref boolean <optional>

prefname to use that stores whether the user chose not to give this prompt again. If no prefname is given the prompt will always be shown.

className string <optional>

the css class attribute to be applied to the dialog icon.

Returns:

returns the name of the button pressed.

Type
String

require("ko/dialogs").prompt( [message] [, opts])

A dialog to query the user for a string in a textbox.

Parameters:
Name Type Argument Description
message String <optional>

The message

opts Object <optional>

Optional object with options

Properties
Name Type Argument Description
prompt string <optional>

text to place before the input textbox.

label1 string <optional>

label to place on the first textbox.

value1 string <optional>

default value for the first textbox.

label2 string <optional>

label to place on the second textbox.

value2 string <optional>

default value for the second textbox.

title string <optional>

dialog title.

mruName1 string <optional>

get an MRU on the first text box.The value of the string is the namespace for the MRU.

mruName2 string <optional>

get an MRU on the second text box. The value of the string is the namespace for the MRU.

validator function <optional>

function(value){} is a callable object to validate the current value when the user presses "OK". It is called with the current value as the only argument. If the function returns false the "OK" is ignored.

multiline1 boolean <optional>

indicates that the first textbox should be multiline

multiline2 boolean <optional>

indicates that the second textbox should be multiline

screenX integer <optional>

position to open the dialog at

screenY integer <optional>

position to open the dialog at

Returns:

It returns null if the dialog was cancelled. Otherwise it returns an array containing the two values entered by the user if label2 was provided, otherwise it just returns the first value.

Type
Array | Null