surveyjs / custom-widgets

The collection of custom widgets for SurveyJS: Survey Library and Survey Creator :package:
https://surveyjs.io
MIT License
79 stars 78 forks source link

Select2 single quote selection issue #262

Closed peteruithoven closed 3 years ago

peteruithoven commented 3 years ago

When we render an dropdown using Select2, when one of the choices contains a single quote (') there is an error when selecting that option.

When selecting opion "b'c" in the example below you'll see the following error.

Survey
.StylesManager
.applyTheme("modern");

var json = {
  "elements": [
    {
      "type": "dropdown",
      "renderAs": "select2",
      "choices": ["a", "b'c"],
      "name": "countries",
      "title": "Please select the country you have arrived from:"
    }
  ]
};

window.survey = new Survey.Model(json);

survey.render("surveyElement");
Uncaught Error: Syntax error, unrecognized expression: option[value='b'c']

Example on Plunkr: https://plnkr.co/edit/LNtxgBNoT1OHjmxg

Ticket: https://surveyjs.answerdesk.io/ticket/details/t7174/select2-single-quote-selection-issue