How to avoid dom flickering? | XM Community
Skip to main content
Solved

How to avoid dom flickering?

  • April 9, 2020
  • 4 replies
  • 56 views

Hi!
I randomized the next button position in order to placed it horizontally in three positions (left, center, right). During the question transition the button flashes in the original location before appearing in the corresponding one (e.g. flashes in the left, and then appear in the right side where it should be). Since my code is in AddOnReady, I tried to change in AddOnLoad but still doing the same.
Thank you in advance for your help!

Best answer by rondev

Try adding below in CSS:
#NextButton{display:none}

4 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • April 9, 2020

Try hiding your button div onload and once the position is set, show the button div


  • Author
  • April 10, 2020

Hi rondev !
I don't really command JS or HTML. I tried adding this to each question but it's not working:
Qualtrics.SurveyEngine.addOnload(function() {

    $('NextButton').hide();
});


Qualtrics.SurveyEngine.addOnReady(function()
{
// First: find the button object itself
var Button = document.getElementById("NextButton");


//In order to change it's horizontal position, we first need to find the "box" holding the button.
var ButtonContainer = Button.parentNode;

ButtonContainer.style.textAlign = Qualtrics.SurveyEngine.getEmbeddedData("Alignment");
 
$('NextButton').show();
});


rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Answer
  • April 10, 2020

Try adding below in CSS:
#NextButton{display:none}


  • Author
  • April 10, 2020

rondev I added it at the beginning and after the current code I have in CSS (Look & Feel) plus the code I posted before in individual questions...but still not working.
CSS (Look & Feel)

Qualtrics.SurveyEngine.setEmbeddedData("Alignment",alignment);
#NextButton{display:none}