Documentation

BX.UI.Dialogs.MessageBox.alert

The method allows to quickly create an advisory dialog (Alert).

Note: When dialog contains a multiline test of layout elements (images, checkboxes and etc) and always specify a title.

BX.UI.Dialogs.MessageBox.alert("Message", (messageBox, button, event) => {});
BX.UI.Dialogs.MessageBox.alert("Message", (messageBox, button, event) => {}, "Next");
BX.UI.Dialogs.MessageBox.alert("Message", "Title");
BX.UI.Dialogs.MessageBox.alert("Message", "Title", (messageBox, button, event) => {});
BX.UI.Dialogs.MessageBox.alert("Message", "Title", (messageBox, button, event) => {}, "Next");

Examples

Method call

BX.UI.Dialogs.MessageBox.alert(
    message: string | Element | Node, 
    okCallback?: Function, 
    okCaption?: string
);

//Method signature with dialog title
BX.UI.Dialogs.MessageBox.alert(
    message: string | Element | Node, 
    title?: string, 
    okCallback?: Function, 
    okCaption?: string
);

Asynchronous callback

BX.UI.Dialogs.MessageBox.alert(
    "Asynchronous button click processing", 
    (messageBox, button, event) => {
        return new Promise((resolve, reject) => {
            console.log("async job started.");
            setTimeout(() => {
                console.log("async job ended.");
                resolve(true);
            }, 3000);
        });
    }
);

The same example, but without promises.

BX.UI.Dialogs.MessageBox.alert(
    "Manual asynchronous button click processing", 
    (messageBox, button, event) => {

        console.log("async job started.");
        button.setWaiting();

        setTimeout(() => {
            button.setWaiting(false);
            messageBox.close();
            console.log("async job ended.");
        }, 3000);
    }
);
© «Bitrix24», 2001-2024