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

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 inputeid] name]", $this).on("change", function () {
        if (isMobile && jQuery(this).closest(".ChoiceRow").nextAll(".ChoiceRow").length === 0) {
            jQuery(this).closest(".ChoiceRow").find("thCid]").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 -

 

 

 

 

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


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