Is there any way to trigger the code behind enableModifiedFlag from CCSJ or SSJS?

前端 未结 2 1027
慢半拍i
慢半拍i 2020-12-10 19:22

If I set enableModifiedFlag property to true on my Custom Control; I see the following code at the bottom of generated Page source.

Everything works fine when user m

相关标签:
2条回答
  • 2020-12-10 19:52

    On click of the button, use below CSJS: XSP._setDirty(false,"") That'll make the document as non dirty and let user navigate to other page.

    0 讨论(0)
  • 2020-12-10 20:02

    By using XSP._isDirty() from CSJS you can get true if any field was modified or false if no changes were done to your form.

    So I added this block of code to my button under CSJS to display same default alert from XPages:

    if (XSP._isDirty()){
        if (confirm ("Are you sure you want to navigate away from this page?" + "\n" + "\n" +
        "This document may contain unsaved changes." + "\n" + "\n" +
        "Press OK to continue, or Cancel to stay on the current page.")){
            return true;
        }else{
            return false;
        }
    } else {
        return true;
    }
    
    0 讨论(0)
提交回复
热议问题