如何在sapui5中的sap.m.MessageBox上绑定事件?

Tin*_*hen 0 sapui5 sap-fiori

我正在 Explored 中使用这个 MessageBox 演示。如何在按钮上绑定事件:MessageBox.Action.YES/“自定义按钮”?

MessageBox.show api中,我只找到了onClose参数。

小智 5

下面的示例展示了如何在 MessageBox.confirm 方法中处理“确定”、“取消”和“自定义按钮”:

    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
            }
        }
    });
Run Code Online (Sandbox Code Playgroud)