Qualtrics survey engine appears to be running twice (at least in preview) | Experience Community
Skip to main content

Qualtrics survey engine appears to be running twice (at least in preview)

  • Jan 19, 2023 12:21 AM UTC
  • 6 replies
  • 508 views

Forum|alt.badge.img+4

This behaviour has been fouling a more complicated survey, so I tried with only a single question. I have added javascript to my questions as follows:
Screenshot 2023-01-18 at 7.11.59 PM.pngEach of these functions appears to be getting called twice in preview mode. Here's what the console looks like:
Screenshot 2023-01-18 at 7.11.11 PM.pngSo OnLoad then On read is run (x2) then onunload (x2).
This means that any variables that I'm assigning are getting cleared null and causing major complications with my more complicated survey. This behaviour just doesn't seem kosher - any ideas on what's happening? I think it might be a JTE thing?
Regards,
Jesse

6 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Jan 19, 2023 5:00 AM UTC

It does that in preview. Once for the desktop and once for the mobile preview.
Doesn't happen when published.


ArunDubey
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+41
  • QPN Level 8 ●●●●●●●●
  • Jan 19, 2023 6:16 AM UTC

Since there is modile view along with desktop view in preview link. That's why each function is appearing twice.


Forum|alt.badge.img+4
  • Author
  • Level 1 ●
  • Jan 19, 2023 2:10 PM UTC

How to I get it to only preview desktop or mobile? it's causing major issues in debugging my code and I'm not sure it will work.
not accepted answer, but I don't know how to remove it


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • Jan 19, 2023 3:09 PM UTC

Publish. Use the anonymous link to test.


ArunDubey
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+41
  • QPN Level 8 ●●●●●●●●
  • Jan 19, 2023 4:46 PM UTC

Yes, use anonymous link. Do not complete your test run while debugging your code and delete all partial response after each test run.


Forum|alt.badge.img+3
  • Level 1 ●
  • Mar 3, 2025 1:29 PM UTC

You can add Javascript at the top, so that in case of mobile preview, the rest of the Javascript is not executed:

if (jQuery(this.questionContainer).parents('.MobilePreviewFrame').length) {
console.log('Mobile Preview - skipping rest of addOnload')

return true
}