简体   繁体   English

Oracle Apex。如果有未保存的更改,请停止页面卸载(单击导航链接时)

[英]Oracle Apex.Stop a page unload(when clicked on a navigable link) if there are any unsaved changes

I'm currently using oracle apex. 我目前正在使用oracle apex。 I created a wizard progress list for my page with the labels in the list as navigable links. 我为页面创建了一个向导进度列表,列表中的标签为可导航链接。 But when the user clicks on these links to navigate to another page i need to ask the user if he's sure as there are unsaved changes, probably using apex.message.confirm() . 但是,当用户单击这些链接导航到另一个页面时,我需要询问用户是否确定有未保存的更改(可能使用apex.message.confirm() I made it navigable by using href="my_link" in the list entry label while creating list in shared components. 在共享组件中创建列表时,通过在列表条目标签中使用href="my_link"使其可导航。 I know if i add onClick="my_function();" 我知道是否要添加onClick="my_function();" i can direct add functionality to that link.But where to add this javascript function at the application level? 我可以直接向该链接添加功能。但是,在应用程序级别在何处添加此javascript函数? How do i do that? 我怎么做? any ideas? 有任何想法吗?

Note : I cant use warn on unsaved changes option at the page level. 注意:我不能在页面级别使用警告未保存的更改选项。 Because iam submitting the values in my page to the db through dynamic action(pl/sql code). 因为iam通过动态操作(pl / sql代码)将页面中的值提交给db。 So even after clicking on save and inserting data into DB, when i try to navigate to other page it will show warning on unsaved changes. 因此,即使单击保存并将数据插入数据库后,当我尝试导航到其他页面时,它也会在未保存的更改上显示警告。 I cant use submit page on click of save button as it is refreshing the whole page and it is not desired. 我无法使用“保存”按钮单击提交页面,因为它刷新了整个页面,因此不希望使用。

Page properties -> Navigation -> Warn on Unsaved Changes set to Yes . 页面属性-> Navigation -> Warn on Unsaved Changes发出Warn on Unsaved Changes设置为Yes After that it will work automatically. 之后它将自动运行。 Works in APEX 5. 适用于APEX 5。

To cancel checks of unsaved changes, use JavaScript function apex.page.cancelWarnOnUnsavedChanges(); 要取消未保存更改的检查,请使用JavaScript函数apex.page.cancelWarnOnUnsavedChanges(); . For example, if you save data with the DynamicAction, add additional true action with type Execute JavaScript Code and call it there. 例如,如果使用DynamicAction保存数据,则添加附加的true动作,其类型为Execute JavaScript Code然后在其中调用它。

By using onClick ="my_function();" 通过使用onClick ="my_function();" in the name provided while filling in the list entry label in the shared components for list , you can define what needs to be done when clicked on the link. 在填写用于列表的共享组件中的列表条目标签时提供的名称中,可以定义单击链接时需要执行的操作。 "my_function" can then be declared at the page level in the function and global variable declaration section. 然后,可以在function and global variable declaration部分的页面级别上声明"my_function" For example: 例如:

<a href="#" onClick="my_function('28');">&F300_LABEL_TEXT.</a>

will be the list entry label at the shared components! 将成为共享组件上的列表条目标签! and in the function and global variable declaration section at the page level. 并在页面级的function and global variable declaration部分中。

    function my_function(page){
        if (apex.page.isChanged() == true)
          {apex.message.alert("there  are unsaved changes"); 
       else{apex.navigation.redirect("f?p="+$v('pFlowId')+":"+page+":"+$v("pInstance")+"::NO");}
                  }           

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM