Does anyone know how to auto-close matrix, accordian-style questions in the new layout view? (There doesn’t seem to be a th[id] element.)
Thanks for any ideas!
New layout view -- accordian does not auto-close after response
Best answer by Tom_1842
I think .grid-cell is only available in the desktop matrix layout. For Mobile Friendly Matrix Questions in the New Survey Taking Experience, the following is working for me to collapse a statement after an answer is selected:
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
document.addEventListener('click', function (e) {
const choice = e.target.closest('.likert-input');
if (!choice) return;
const statement = choice.closest('.matrix-statement');
if (!statement) return;
requestAnimationFrame(() => {
const button = statement.querySelector('.foldout-carrot');
if (
button &&
button.getAttribute('aria-expanded') === 'true'
) {
button.click();
}
});
});
});
If you'd like to automatically move respondents through the matrix statements, this version collapses the current statement, opens the next one if it's collapsed, and scrolls it into view:
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
document.addEventListener('click', function (e) {
const choice = e.target.closest('.likert-input');
if (!choice) return;
const statement = choice.closest('.matrix-statement');
if (!statement) return;
requestAnimationFrame(() => {
// Collapse current statement
const button = statement.querySelector('.foldout-carrot');
if (
button &&
button.getAttribute('aria-expanded') === 'true'
) {
button.click();
}
// Find next statement
const nextStatement = statement.nextElementSibling;
if (
nextStatement &&
nextStatement.classList.contains('matrix-statement')
) {
const nextButton =
nextStatement.querySelector('.foldout-carrot');
// Expand if currently collapsed
if (
nextButton &&
nextButton.getAttribute('aria-expanded') === 'false'
) {
nextButton.click();
}
// Scroll into view
nextStatement.scrollIntoView({
behavior: 'smooth',
block: 'nearest'
});
}
});
});
});
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community.
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community.
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community.
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
