3.5.2.3Manually destroying common dialogs

As described above, the initial update message from the dialog gives you its ID, in Msg.widgetId, and that makes it possible for you to use Framework.DestroyDialog() to close the dialog. For example, the following Ask() cancels itself if the user does not respond within 5 seconds:

Framework.Ask({

title: "Are you sure?",

text: "You have 5 seconds to answer...",

}, function (Msg) {

if (!Msg.result) {

// No .result in message. Therefore, it's the initial creation of the dialog.

// Set a timer which destroys the dialog after 5 seconds if the

// user has not answered.

setTimeout(function() {

Framework.DestroyDialog(Msg.widgetId);

}, 5000);

} else {

// Result from the dialog. Can either be the user clicking the button,

// or termination of the dialog by the above DestroyDialog()

}

});