alert of common helpers, Methods Webix Docs
string|functionoptional, the type of an alert modal box or the callback function callback
functionoptional, the callback function (can be used, if the modal box type is defined as a second parameter)
| promise | the Promise object |
Example
// basic initialization
webix.alert("Test alert","alert-warning").then(function(result){
// some action
});
// extended initialization
webix.alert({
title: "Close",
text: "You can't close this window!",
type:"alert-error"
}).then(function(result){
// some action
});
Related samples
Details
The method can be used in several ways:
1. Basic form - contains several parameters: text (mandatory) and type.
webix.alert("Test alert","alert-warning");
In the basic form, the method may take the following parameters:
- text - (string) the text in the alert (obligatory);
- type of the modal box as a string (can be set as "alert-warning" or "alert-error"), or the callback function (optional);
- callback - (function) the callback function (optional).
2. Extended form - contains an object with several available parameters. Non-specified parameters take default values.
webix.alert({
title:"Custom title",
ok:"Custom text",
text:"Result: yes",
type:"alert-warning"
});
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 text of the window body
- ok - (string) the text of the 'Ok' button
- type - ("alert-warning" or "alert-error") the alert type: warning or error
- css - (string) the CSS class for styling the alert box
- container - (string,HTMLElement) the container for the alert box
- callback - (function) the callback function (optional)
The full list of possible box parameters is given in the related article.
Callbacks
Since webix.alert() 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 alert result status (true).
// basic form
webix.alert("Test alert","alert-warning",function(result){
webix.message(result);
});
// extended form
webix.alert({
title: "Close",
text: "You can't close this window!",
type:"alert-error",
callback:function(result){
webix.message(result);
}
});
See also
Back to top