Question T2380
Visible to All Users

Loading Survey Data + ChoicesFromURL resets to first page

created 6 years ago (modified 6 years ago)

Hi,

I've been recently upgrading SurveyJS in our application from 1.0.46 to 1.1.0, which I've noticed that when loading survey.data from localstorage and a question that is loaded from an URL is used to show and hide page visibility that it keeps reseting the page to the first page.

Example

https://plnkr.co/edit/EoLmxHK5phlxesTi3Zle?p=preview

This survey should remember what page you are on, and what you have answered, but it forgets the page, so first select any answer on page 1, then goto the next page; if you then reload/refresh the page it takes you back to page 1 and not page 2.

original issue

Originally I thought this was only to do with custom widgets, so in our custom widgets which get it's data from an API that the call back for choices changed 'choicesChangedCallback' no longer works or has disappeared, are we still able to listen for this callback?

I've tried to using 'registerFunctionOnPropertyValueChanged' listening for 'visibleChoices' instead but with no luck.

Example -

question.choicesChangedCallback = function() { render(question, el);};

Any help will be much appreciated

Thank You.

Answers approved by surveyjs Support

created 6 years ago

Hello James,
You have got it right. The function should work correctly. Could you please review this code: select2 and select2_tagbox.
If you create an example in plunker with your custom widget then we look at it.

Thank you,
Andrew
SurveyJS Team

    Show previous comments (3)

      Hello James,
      Here is what happens here. We added the code that resets the checkbox value on setting choices from the restful service. We needed it to fix the issue on complex values in checkbox/dropdown when value is complex, for example: {id: 3, score: 6}. On setting the undefined value the page2 becomes invisible for a moment and as result the next visible page becomes page1.
      I have fixed this behavior on this commit. I have added the corresponded unit test.
      We will release new minor version probably tomorrow. It will contains the bug fix.

      Thank you,
      Andrew
      SurveyJS Team

        Hi Andrew,

        Oh awesome, that makes perfect sense on why it was jumping and not setting back to the correct page, thank you so much for this, you saved me a massive head-ache!!

        • James

          You are very welcome!
          It was the bug in the library on this very specific scenario.

          Thank you,
          Andrew
          SurveyJS Team