Position of addOnUnload | XM Community
Skip to main content

For a particular question I have, I find that I need to put Qualtrics.SurveyEngine.addOnUnload() within Qualtrics.SurveyEngine.addOnReady(). The solution seems to work, but I am a bit unsure if this might cause other problems. As such, I'd like to ask experts here the following questions.
1) Will there be problems if put addOnUnload() inside addOnReady()? My code structure looks like:
Qualtrics.SurveyEngine.addOnReady(function(){
Some complicated event listener that calls this.enableNextButton()
    Qualtrics.SurveyEngine.addOnUnload(function(){
Remove event listener
   });
});
2) There is another object that I need to remove on unload. To keep things neater, I want to put that after the closing of addOnReady(). Hence, I will have two addOnUnload() blocks. Will that cause problems?

PO_sg
Ideally it shouldn't be of any issue.
You can try addOnPageSubmit ( f ) at one place if it helps! .
For more info (https://api.qualtrics.com/ZG9jOjIwMTY2NzUy-javascript-question-api)
Hope it helps!


PO_sg ,
Answers to your questions:

  1. No, putting addOnUnload() inside addOnReady() won't cause any problems.

  2. Having more than one addOnUnload() won't cause any problems.


Leave a Reply