Question T6357
Visible to All Users

Slider disappearing from server-side JSON after saving

created 5 years ago

Hello,
we have come across a problem while trying to make a question with a slider.
We copied the code from this page: https://plnkr.co/edit/9I7RCPi5esDHby8hGIvq?p=preview&preview onto the server JSON,

JSON
{ "type": "nouislider", "name": "range", "title": "Please range" }

However, whenever we left the JSON editor to check the survey in the survey designer, it did not show any question of type "nouislider" or "bootstrapslider". When we went back to the JSON editor, the piece of code describing the slider question was gone.

Could it be that, since the slider classes are third-party additions, downloading the JSON from the server is not an option?

I would appreciate it if you could help me with this problem.

Answers approved by surveyjs Support

created 5 years ago

Hello,
Please make sure to include scripts that requires for uislider. It is a third-party widget and not ours.
You will need:

HTML
<script src="https://unpkg.com/nouislider@9.2.0/distribute/nouislider.js"></script>

and probably jQuery and our custom widget script:

HTML
<script src="https://unpkg.com/surveyjs-widgets@1.8.31/surveyjs-widgets.js"></script>

Thank you,
Andrew
SurveyJS Team

    Comments (3)

      You can investigate the following example.

      Thank you,
      Andrew
      SurveyJS Team

        Thank you for your answer! The thing is that we did include the script in our html file and the problem was that the code for "nouislider" or "bootstrapslider" type question written in JSON editor keeps disappearing without being saved on the server. We were thinking that maybe we should just include the entire code for our survey instead of using "load Survey JSON from server" function… We would appreciate if you could help us with this problem.

          Hello Yennie,
          Unfortunately, it is impossible to help without being able to reproduce the issue.
          If you tell that the JSON is changing during saving it on the server side, then please try to isolate the reason of the issue.
          Could you check do you have the Slider in your JSON before saving it on the server?
          Something should remove the slider JSON. We definitely do not remove it it works in many projects.

          Typically, the issue is that the correct JSON comes to the page where you run the survey, but the Slider class is not registered in the SurveyJS Library Custom Widgets, commonly because scrips are not on the page or they loaded after Survey loads JSON.
          If a custom widget is not registered in Survey Library, then Serializer could not recognize the question class and simply ignored it. You can investigate survey.jsonErrors array property to see errors on loading errors.

          JavaScript
          /**    * The list of errors on loading survey JSON. If the list is empty after loading a JSON, then the JSON is correct and has no errors.    * @see JsonError    */   public jsonErrors: Array<JsonError> = null;

          Thank you,
          Andrew
          SurveyJS Team