How to cause last accordion in mobile friendly matrix to auto close upon answer selection? | XM Community
Skip to main content
Solved

How to cause last accordion in mobile friendly matrix to auto close upon answer selection?

  • September 17, 2021
  • 2 replies
  • 185 views

I am working on a mobile friendly accordion style matrix question and the UI for the first 3 statement options auto collapses the accordion to show the next statement. How do I achieve the same effect for the 4th and final statement before the user would continue to the next question?
image.png

Best answer by ChiragK

Hi Jared, Try adding this JavaScript code in that question.
Qualtrics.SurveyEngine.addOnReady(function () {
    var $this = jQuery(this.questionContainer);
    var isMobile = jQuery(".QuestionBody", $this).is(".mobile");
    jQuery(".ChoiceRow input[id][name]", $this).on("change", function () {
        if (isMobile && jQuery(this).closest(".ChoiceRow").nextAll(".ChoiceRow").length === 0) {
            jQuery(this).closest(".ChoiceRow").find("th[id]").click();
        }
    });
});

View original

2 replies

Forum|alt.badge.img+8
  • Level 2 ●●
  • 77 replies
  • Answer
  • September 22, 2021

Hi Jared, Try adding this JavaScript code in that question.
Qualtrics.SurveyEngine.addOnReady(function () {
    var $this = jQuery(this.questionContainer);
    var isMobile = jQuery(".QuestionBody", $this).is(".mobile");
    jQuery(".ChoiceRow input[id][name]", $this).on("change", function () {
        if (isMobile && jQuery(this).closest(".ChoiceRow").nextAll(".ChoiceRow").length === 0) {
            jQuery(this).closest(".ChoiceRow").find("th[id]").click();
        }
    });
});


  • Author
  • 1 reply
  • September 22, 2021

Thank you! This worked like a charm!


Leave a Reply