I am using this MessageBox demo in Explored. How to bind event on buttons: MessageBox.Action.YES/"Custom Button" ?
In MessageBox.show api, I only found onClose
parameters.
Here's an example that shows how to handle the OK, CANCEL, and a "Custom Button" within the MessageBox.confirm method:
MessageBox.confirm(sText, {
title: sTitle,
initialFocus: sap.m.MessageBox.Action.CANCEL,
onClose: function(sButton) {
if (sButton === MessageBox.Action.OK) {
// Action for the OK button
} else if (sButton === MessageBox.Action.CANCEL) {
// Action for the CANCEL button
} else if (sButton === "Custom Button") { // Fixed the missing quote here
// Action for the custom button
}
}
});