I get an unexpected page break after questions with javascript | XM Community
Skip to main content

I have written some simple scripts to act in the place of display logic as it does not work for what I am trying to do (in page logic based on embedded data), but although my scripts work as expected, I get an unexpected pagebreak mid-block after my set of javascripted questions. This breaks my survey as all the questions in a block must appear on the same page. What could be causing this, and how do I fix it?
My scripts are all like this:
Qualtrics.SurveyEngine.addOnload(function(){
var ans = parseInt( "${e://Field/randomnumber0}" )
if(ans!=11 ){
jQuery("#"+this.questionId).hide();
}

});

Are you using the in page display logic on the same question as the JS. If yes, then that could be the issue.
Basically the sytem is getting confused whether to show the question or not.


Nope, nothing other than the JS determining if a question is shown. The questions with JS show up as expected, it is the question immediately following the JS questions that is incorrectly displayed on the following page, and it has no display control.


Hmm. Have you tried moving your code to addonReady?
I faced a similar issue quite a while back, I think I was randomizing the questions and then using JS to hide them. But, I think rather than a page break being introduced, my next button was being clicked automatically. Once I moved the code to addonReady it was working properly. Then at onload, rather than hiding, I changed opacity to 1%. So things were fine.


I have found what was happening, hidden questions are counting towards the questions per page limit.


Oh!


Leave a Reply