oTree Forum >

How to include JS properly.

#1 by henning99 (edited )

Hello,

I have a problem regarding implementing my non-oTree HTML, CSS, JS files into oTree format. I have this puzzle game (see screenshot 1). Implemented in oTree it is buggy - as you can see in screenshot 2. The JS logic kinda works as the counter recognises clicks on the here empty and buggy structured picture pieces. 

If you maybe know why this is happening please let me now. If you need the code just let me know. 

Kind regards :)

#2 by BonnEconLab

It seems to me that your HTML template or JavaScript does not find the images that it is supposed to load.

Have you had a look at https://otree.readthedocs.io/en/latest/templates.html#images-static-files?

Do you succeed to include the images at a different place in the template, following the instructions on https://otree.readthedocs.io/en/latest/templates.html#images-static-files?

#3 by henning99

I read it but I don't know where to include the <img> tags since the HTML file does not access the picture files. Only the JS code does.

#4 by Fanist

What is the JS code for image loading? It seems that JS cannot find the image path.

#5 by henning99

Hey guys,
sorry for the late answer. I attached the JS code. I put the JS code within the _static folder of my oTree project. Within _static I created a folder exactly named like the app where the images, CSS and the JS files are laying. Should I try to implement the files within the HTML files directly?

Write a reply

Set forum username