surveyjs/custom-widgets

Select2 single quote selection issue

peteruithoven opened this issue · 0 comments

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