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 messageString The message
optsObject <optional>
Optional object with options
Properties
Name Type Argument Description titlestring <optional>
dialog title
-
require("ko/dialogs").confirm(message [, opts])
-
Ask the user for confirmation
Parameters:
Name Type Argument Description messagestring The message
optsobject <optional>
Optional object with options
Properties
Name Type Argument Description responsestring <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".
textstring <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.
titlestring <optional>
dialog title
doNotAskPrefstring <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.
yesstring <optional>
override the label for the yes button (defaults to Ok)
nostring <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 messageString The message
callbackfunction function to handle
optsObject <optional>
Optional object with options
Properties
Name Type Argument Default Description messagestring <optional>
The message
pathstring <optional>
Location to open file picker at
typestring <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 messageString The message to be displayed to the user
optsobject <optional>
Optional object with options
Properties
Name Type Argument Description promptstring <optional>
Message to show as the prompt
buttonsstring | 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.
responsestring <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".
textstring <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.
titlestring <optional>
dialog title
doNotAskPrefboolean <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.
classNamestring <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 messageString <optional>
The message
optsObject <optional>
Optional object with options
Properties
Name Type Argument Description promptstring <optional>
text to place before the input textbox.
label1string <optional>
label to place on the first textbox.
value1string <optional>
default value for the first textbox.
label2string <optional>
label to place on the second textbox.
value2string <optional>
default value for the second textbox.
titlestring <optional>
dialog title.
mruName1string <optional>
get an MRU on the first text box.The value of the string is the namespace for the MRU.
mruName2string <optional>
get an MRU on the second text box. The value of the string is the namespace for the MRU.
validatorfunction <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.multiline1boolean <optional>
indicates that the first textbox should be multiline
multiline2boolean <optional>
indicates that the second textbox should be multiline
screenXinteger <optional>
position to open the dialog at
screenYinteger <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