在 Apex 5.0 中关闭模态对话框页面之前的确认

Confirmation before closing a modal dialog page in Apex 5.0

我正在尝试在使用 (X) 按钮关闭模式对话框页面时创建一个简单的确认 ("Do you want to close this window?")。

在 Apex 5.0 中实现此功能的最有效方法是什么?

我尝试使用对话框关闭事件实现一个解决方案,但是这似乎对使用 (X) 按钮关闭对话框没有影响。

您是否考虑过通过单击 "cancel" 按钮隐藏按钮 (x) 并取消模式对话框页面?

尝试在页面加载时使用该代码在您的模态页面中创建动态操作:

你的 da 应该执行 javascript 代码:

var button = parent.$('.ui-dialog-titlebar-close'); //get the button
button.unbind(); //remove the behavior

//put another behavior to the button
button.on('click', function() {
   apex.message.confirm( "Your message here", function( okPressed ) { 
      if( okPressed ) {
          apex.navigation.dialog.cancel(true);
      }
   });
});

尝试确认 "X" 按钮是否有 css class "ui-dialog-titlebar-close",它们可以在不同版本的 apex 之间切换。 如有必要,请使用正确的 class.

更新代码的第一行

如果要重命名确认中的标准按钮名称 window,请使用:

apex.lang.addMessages({"APEX.DIALOG.OK": pOkLabel});
apex.lang.addMessages({"APEX.DIALOG.CANCEL": pCancelLabel});