Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Problem while loading external javascript file

  • NeoFlex
  • NeoFlex's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago #203113 by NeoFlex
Hello,

In my survey, I load an external Java script file with each question group. I use this to access the slider in my three sub-questions that make up my question in each group. I have now found that my script file does not always load or run when I start the survey in the preview. I first thought this was a caching issue, so I added a query string to the script URL. But nothing happened. It's just not possible for me to find the mistake. So i ask here. Maybe you have an idea.

I attached an lss file.
The topic has been locked.
  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #203115 by holch
Are you testing the whole questionnaire, the question group or the question?

I answer at the LimeSurvey forum in my spare time, I'm not a LimeSurvey GmbH employee.
No support via private message.

The topic has been locked.
  • NeoFlex
  • NeoFlex's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago #203128 by NeoFlex
I have this problem only when i test the whole survey.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #203150 by tpartner
Replied by tpartner on topic Problem while loading external javascript file
I don't understand why you are creating and inserting the script element via jQuery. Why not insert it directly with a <script> tag?

Code:
<script type="text/javascript" src="https://pathTo/lsScript.js"></script>

I'm also not sure why you are inserting the custom.css file via jQuery. It should already be loaded and this will not update the assets cache.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • NeoFlex
  • NeoFlex's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago #203292 by NeoFlex
Because I want to make sure that the script element is loaded and executed with every newly displayed question group. The same applies to the css file. Also there I want to make sure that the custom.css is loaded and overwrites the defaults.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago - 3 years 8 months ago #203315 by tpartner
Replied by tpartner on topic Problem while loading external javascript file

Because I want to make sure that the script element is loaded and executed with every newly displayed question group.

Placing my snippet in the group description will load the remote JS file.


Also there I want to make sure that the custom.css is loaded and overwrites the defaults.

The theme custom.css file is already automatically loaded.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 3 years 8 months ago by tpartner.
The topic has been locked.
  • NeoFlex
  • NeoFlex's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago #203337 by NeoFlex
Like I already wrote. If I embed the script this way, it won't load or run every time the question group is displayed. I checked that with a small console output that I integrated into the remote script. The problem then unfortunately remained with my current approach. Therefore my message in the forum. Maybe it's because I'm accessing the slider objects to change their properties. I deactivated that function and it worked so far.

I have already seen that custom.css is always loaded last. But also here I have the problem that the defaults are not overwritten with the setups in custom especially on the sliders.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 8 months ago #203338 by DenisChenu
Replied by DenisChenu on topic Problem while loading external javascript file

tpartner wrote:

Also there I want to make sure that the custom.css is loaded and overwrites the defaults.

The theme custom.css file is already automatically loaded.

Yes …but …

Theme system sometimes load theme.css after custom.css … or core css

See bugs.limesurvey.org/view.php?id=14090 for example

In Skelvanilla : i load in it twig : gitlab.com/SondagesPro/SurveyThemes/skel...ws/header/theme.twig not by option …

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • NeoFlex
  • NeoFlex's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
3 years 8 months ago #203344 by NeoFlex
Interesting....so maybe this bug still exist in 3.15.1+181017.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose