How to copy a project without having to fix JavaScript and CSS later? | XM Community
Skip to main content

Hi everyone,
this is my first question in this community and I am excited to hear back from you.
I copied a project to the library to share it with others. When I previewed the copied project I noticed that it looked different than the original one. Some background colors, fonds, and elements were slightly different. I looked into it and found out that the project includes some custom JavaScript and CSS (which wasn't added by me). Some issues I could fix by changing the QID. They were hard coded and, therefore, referencing to the original question. It was quite tricky to figure out the right QID. Typing CTRL+S finally got me there, since it shows the right QID shortly while saving. Unfortunately, some things are still not quite right. I attached the code and have two questions:

  1. How can I avoid this from happing in general?

  2. How can I fix my current JavaScript and CSS code so that my copied project looks exactly like the original one? (in Q2 it might have something to do with the labels)

Thank you.
Best,
Jack
Q1.txtQ2.txtCustom_CSS.txt

In general, you shouldn't hard code QIDs and choice ids in JavaScript. Exceptions are extremely rare and certainly not needed in your example.
In your case, most of the JS could probably be replaced with some CSS rules. The remainder could be rewritten without hardcoded QIDs or choice ids.


Hi TomG.
Thank you for getting back to me. I am glad that there is better way to do it. The question is how do I do it? I am not very familiar with JS and CSS.


Leave a Reply