Javascript displaying adjustable chart on first question, but not subsequent questions? | XM Community
Skip to main content
Solved

Javascript displaying adjustable chart on first question, but not subsequent questions?


Forum|alt.badge.img
Hi all,

I have an issue displaying a chart that is drawn in javascript- it works on the first question block, but not in subsequent blocks & questions in preview mode, and via anonymous link. The charts display fine when the questions/ blocks are previewed in isolation within the editor. I've attached the qsf- does anybody have experience with this issue?

Many thanks!

Best answer by NiC

Hi @cjohnburke,

So the issue you are facing here is due to duplicate id's
Adding the following code in addOnUnload function for every question you have the chart code on should solve your problem:

`jQuery("#myChart").remove(); `

Attached the updated qsf i tried the code and charts are working on
View original

2 replies

NiC
QPN Level 5 ●●●●●
Forum|alt.badge.img+27
  • QPN Level 5 ●●●●●
  • 255 replies
  • Answer
  • March 14, 2019
Hi @cjohnburke,

So the issue you are facing here is due to duplicate id's
Adding the following code in addOnUnload function for every question you have the chart code on should solve your problem:

`jQuery("#myChart").remove(); `

Attached the updated qsf i tried the code and charts are working on

Forum|alt.badge.img
  • Author
  • 12 replies
  • March 21, 2019
Thank you @NiC ! THis worked. The other thing that worked was disabling page transitions in the look and feel editor.

Leave a Reply