Collapsing last row of matrix question in mobile/accordion view | XM Community
Skip to main content
Question

Collapsing last row of matrix question in mobile/accordion view

  • November 22, 2024
  • 2 replies
  • 65 views

Forum|alt.badge.img+2

Hi,

I’m trying to get a matrix question that’s in accordion/mobile view to collapse the last row when a value is entered (like it already does for all the other rows). I found a super helpful answer here, which uses this code:

    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();
        }
    });

This works great for me, except for one minor thing -- when the user hits the next button, the last row expands again. This happens regardless of whether I add the code to ‘addOnReady’ or ‘addOnLoad.’

Any suggestions on how to keep the last row from re-expanding would be greatly appreciated - thanks -

 

 

 

 

2 replies

  • Level 4 ●●●●
  • 209 replies
  • November 25, 2024

It still works for me. Make sure you published the survey. Give a try again. 


Forum|alt.badge.img+2
  • Author
  • Level 1 ●
  • 7 replies
  • November 27, 2024

Thanks - I just tried testing it again after publishing it, but yeah, I still see the last row re-expand when I move to the next question.


Leave a Reply