confirm

creates a confirm box

promise confirm(string|object text, [string|function type,function callback] );
textstring|objectmandatory, the box text as a string, or the box configuration object
typestring|functionoptional, the type of a confirm 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.confirm("Test confirm", "confirm-warning")
    .then(function(result){
        webix.message(result);
    })
        .fail(function(){
            webix.message("Cancel");
        });
 
// extended initialization
webix.confirm({
    title: "Close",
    text: "You can't close this window!",
    type:"confirm-error"
})
    .then(function(result){
        webix.message(result);
    })
        .fail(function(){
            webix.message("Cancel");
        });

Related samples

Details

The method can be used in 2 ways:

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

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

2. 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 - ("confirm-warning" or "confirm-error") the confirm type: warning or error
  • css (string) the CSS class for styling the confirmation 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.

webix.confirm({
    title: "Close",
    text: "You can't close this window!",
    type:"confirm-error"
});

Callbacks

Since webix.confirm() 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 confirm result status (true or false).

// basic initialization 
webix.confirm("Test confirm", "confirm-warning", function(result){
    webix.message(result);
});
 
// extended initialization
webix.confirm({
    title: "Close",
    text: "You can't close this window!",
    type:"confirm-error",
    callback:function(result){
        webix.message(result);
    }
});
See also
Back to top