prompt

creates a message box with an input

promise prompt(string|object text, [string|function type,function callback] );
textstring|objectoptional, the prompt text as a string, or the prompt configuration object
typestring|functionoptional, the type of a prompt modal box or the callback function
callbackfunctionoptional, the callback function (can be used, if the modal box type is defined as a second parameter)
promisethe Promise object

Example

// basic initialization
webix.prompt("Prompt message",  "prompt-warning", function(result) {
// some code
});
 
// extended initialization
webix.prompt({
  title: "A prompt dialog",
  text: "Type something",
  ok: "Submit",
  cancel: "Cancel",
  input: {
    required:true,
    placeholder:"This field is required",
  }
}).then(result => {
 // do something
});

Related samples

Details

The method can be used in 2 ways:

1. In the Basic form, the method may take the following parameters:

  • text - (string) the text of the prompt body (obligatory);
  • type of the modal box as a string (can be set as "prompt-warning" or "prompt-error"), or the callback function (optional);
  • callback - (function) the callback function (optional).
webix.prompt("Test prompt", "prompt-error");

2. Extended form - contains an object with several available parameters. Non-specified parameters take default values.

webix.prompt({
  title: "Prompt title",
  text: "Prompt text",
  ok: "Submit",
  cancel: "Cancel",
  input: {
    required:true,
    placeholder:"This field is required",
  }
});

In the extended form, the method takes one parameter - an object with box parameters. The parameters are:

  • title - (string) the text of the header
  • text - (string) the box text
  • ok - (string) the text of the 'Ok' button
  • cancel - (string) the text of the 'Cancel' button
  • type - ("prompt-warning" or "prompt-error") the prompt type: warning or error
  • css (string) the CSS class for styling the prompt box
  • container - (string,HTMLElement) the container for the confirm box
  • callback - (function) the callback function (optional)

The full list of possible box parameters is given in the related article.

Callbacks

Since webix.prompt() returns a promise, there is no need in a callback functions. However, you can add a callback if this is necessary. As a parameter, the function receives the prompt result status (true or false).

// basic initialization
webix.prompt("Prompt message",  "prompt-warning", result => {
// some code
});
 
// extended initialization
webix.prompt({
  title: "A prompt dialog",
  text: "Prompt message",
  ok: "Submit",
  type: "prompt-warning",
  cancel: "Cancel",
  callback: function(result) {
    // do something
  }
});
Back to top