Does anyone know how to auto-close matrix, accordian-style questions in the new layout view? (There doesn’t seem to be a thtid] element.)
Thanks for any ideas!
Hi
In Qualtrics, the new layout view might not have a straightforward way to auto-close matrix questions with accordion-style formatting. You can give a try with JavaScript
//JavaScript//
Qualtrics.SurveyEngine.addOnload(function() {
// Function to collapse all matrix questions initially
function collapseMatrixQuestions() {
var matrixQuestions = document.querySelectorAll('.MatrixQuestion');
matrixQuestions.forEach(function(question) {
var accordionToggle = question.querySelector('.AccordionContent');
if (accordionToggle) {
accordionToggle.click(); // Simulate a click on the accordion toggle to collapse the question
}
});
}
// Call the function to collapse matrix questions on page load
collapseMatrixQuestions();
});
Thank you!
Hi,
Thanks so much for providing the script! Unfortunately, I think there’s something in this style that prevents your and my scripts from working.
I am grateful for your generosity!
For anyone looking, this is how we handled auto-close matrix accordion-style questions in the newer Simple layout (using jQuery):
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
// Attach a click event to all elements with the class 'grid-cell.accordion'
$('.grid-cell.accordion').on('click', function() {
let matrixStatement = $(this).closest('.matrix-statement');
matrixStatement.find('.matrix-statement-header').trigger('click');
});
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.