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

问题描述 投票:0回答:3

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

MessageBox.show api中,我只找到了

onClose
参数。

sapui5 sap-fiori
3个回答
5
投票

您错过了哪个活动?

MessageBox.confirm(sText, {
    title : sTitle,
    initialFocus : sap.m.MessageBox.Action.CANCEL,
    onClose : function(sButton) {
        if (sButton === MessageBox.Action.OK) {
            // Do something
        } elseif (sButton === MessageBox.Action.CANCEL) {
            // Do something
        } elseif (sButton === "Custom Button) {
           // Do something
        };
    }
});

0
投票

您的链接指向 SAP 外部人员无法访问的 SAP 内部页面,请务必发布可通过互联网访问的链接。

在这个探索的示例中,您可以看到页脚中的按钮有事件。


0
投票

下面是在消息框中绑定它的示例 与上面的代码相比只有很小的变化

MessageBox.confirm(sText, { 标题 : 标题, 初始焦点:sap.m.MessageBox.Action.CANCEL, onClose : 函数(sButton) { if (sButton === MessageBox.Action.OK) { // 做一点事 } elseif (sButton === MessageBox.Action.CANCEL) { // 做一点事 } elseif (sButton === "自定义按钮) { // 做一点事 }; }.绑定(这个) });

© www.soinside.com 2019 - 2024. All rights reserved.