Issue with Select2 Implementation Duplicating Some Options | XM Community
Skip to main content

I am having trouble with my Select2 implementation. On some questions it works wonderfully, but on others it seems to duplicate the last option in the selection box. It seems to happen to the last option in a group usually, but only once per drop down.

 

For the code in my header, I am using:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/css/select2.min.css"> <script src="https://cdn.jsdelivr.net/npm/select2@4.0.13/dist/js/select2.min.js"></script>

 

For each question:

Qualtrics.SurveyEngine.addOnReady(function()
{
    jQuery("#"+this.questionId+" select").select2();
});

 

I’ve tried remaking the questions and copying a question that works fine, just changing the options, and neither of those solutions have worked.

Update, found out that select2 doesn’t like boxes with both groups and options not associated with a group. Still don’t know how to fix it, but I can at least work around that. If anyone knows an actual fix for the issue, I would love to hear it.


Leave a Reply