How to handle back button?

Home Forums Classic DFFS How to handle back button?

Viewing 2 reply threads
  • Author
    Posts
    • #34202
      Harsh
      Participant

        Hello,
        I have set up dffs form for SharePoint online list,
        So my problem is when user edit any existing item via dffs form and save the items with values, now again if he presses the back button from the browser, some values are changed and goes to different fields.
        How can I handle this?

      • #34209
        Alexander Bautz
        Keymaster

          This is unfortunately not so easy to fix. The browser (or SharePoint) does for some reason have trouble with this when DFFS is used – it is the same issue that occurs when you clone a tab with a NewForm or EditForm open.

          I think it might be because the “save state” functionality saves the input based on the order of the fields in the form, but when DFFS is applied it will reorder the fields and thus change the order of the fields so that the browser (or SharePoint) misplaces the values when the tab is cloned or you use the back button.

          Alexander

        • #34213
          Harsh
          Participant

            Thanks to replay @alexander,
            Is there any fix for this issue?

            • #34215
              Alexander Bautz
              Keymaster

                I looked into it and found a possible solution here: https://stackoverflow.com/a/29127200

                I have modified it slightly, but if you add this to your EditForm Custom JS the page should auto-refresh if the user uses the back button to reopen the EditForm:

                if (history.state !== null && history.state < history.length) {
                    history.replaceState(null, "", window.location.href);
                    spjs.dffs.alert({
                        "title": "Refresh needed",
                        "msg": "You navigated to this form using the back button in your browser and the form needs a refresh...",
                        "noBtn": true
                    });
                    location.href = location.href;
                } else {
                    history.replaceState(history.length, "", window.location.href);
                }

                Alexander

          Viewing 2 reply threads
          • You must be logged in to reply to this topic.