Issue T13969
Visible to All Users

Problem with showPreviewBeforeComplete

created a year ago

I have made the setting showPreviewBeforeComplete: showAnsweredQuestions.

Now I have two problems:

Problem No 1:
When I have 2 questions on two different pages and I klick 'edit' on the preview page on question 1, surveyjs shows me question 2 of the second page instead question 1 on the first page.

Problem No 2:
When the onCurrentPageChanging event is fired I am saving the current data to the database.
So I can save the data during page changes and stay on the page if there is an error on the server while saving the data.
When I klick 'edit' on the preview page on a questions it returns the the survey pages and calls the onCurrentPageChanging event too.
So the data is saved again, if i return to a page.
How can I find out when handling the onCurrentPageChanging event if the user returns in this way to a page (that is already saved), so I prevent saving it again.

Show previous comments (2)
AT AT
Andrew Telnov a year ago

    Hello Peter,
    I think we need a better API here. Probably do not call this event twice on changing from preview to edit or add a new property to the options. I will think about it.
    Here is the dirty work-around:

    JavaScript
    survey.onCurrentPageChanging.add((sender, options) => { if(!options.oldCurrentPage || options.oldCurrentPage.name === "all") return; console.log("onCurrentPageChanging"); survey.notify(SavingMsg, "info"); savePartial(sender, options); });

    Thank you,
    Andrew
    SurveyJS Team

    AT AT
    Andrew Telnov a year ago

      FYI: Here is the related issue on GitHub.

      Thank you,
      Andrew
      SurveyJS Team

      AT AT
      Andrew Telnov a year ago

        FYI: I have fixed the issue by this PR. We will have a new attribute in options: isAfterPreview: boolean. We may change the attribute name before the release.

        Thank you,
        Andrew
        SurveyJS Team