Recent Topics

Where to put java-scripts

Started by on Feb 25, 2018 – Contents updated: Feb 27, 2018

Feb 25, 2018 15:43    

Hi again

Right now I am considering 3 locations for putting javascript:

1: Simply letting them be in my post MARKUP
This has not worked for me so far, and I dont think it was meant to be there in B2E (I only read it's possible to cheat/disable the filter)

2: Putting it in the designated box, under the collections advanced settings.
This has also not worked for me so far. (I allowed admins group css and java, and set security to basic.)

3: Keeping external files.
This seems to be working by including my scripts (in the MARKUP) with, for example:
<script type="text/javascript" src="/media/blogs/exp1/include/js/pickTurn.js"></script>
(I have confirmed that the execution of the script begins)
However I am having problems, the scripts are not working as they do outside B2E

But perhaps lets take the location first, is it fine to have the scripts as separate files ?
(I put the dir shown above, that may not be the best place)

Thanks for all the help :-)

Feb 25, 2018 18:00

  1. Yes scripts can be separate files, b2evo uses lots of [***.js]
  2. It shouldn't matter where they are as long a s a) the calling script has the correct path and b) any call made by the script knows where to pick up data etc.

Feb 25, 2018 23:24

I think it depends on what it is used for. Remember that some scripts may cause conflicts while others will work if they are called in the correct order. Ideally scripts for skins should be called through the skin and those for plugins through the plugins.

Check how your JavaScript works by disabling all plugins and enabling them one by one.

Essentially it doesn't matter which of your above mentioned options you use, provided that you point to them correctly and they do not cause conflicts. Also ensure your script is well formed, because if a script somewhere breaks, it could stop all following scripts to fire also.

To allow us to advise better, perhaps share what your scripts are for, what functions they are required to perform and which libraries they use.

Feb 26, 2018 17:20

Think I got the basic functionality going now:
2 scripts picking 3 random cards and turning them along with a text.

It seems when moving scripts outside the html file, a few things are different.
I had to put single quotes.
And I think my variable names went from non-case-sensitive to case-sensitive (Not absolutely sure about this)

Heres a link

Thanks for the input

SWEET, thought it would be much harder :-D

Feb 26, 2018 18:55

Good to know you've merged your ideas into one site, and are having fun doing it. But look on the bright side, there will probably be harder things to do when you least expect it :)

Feb 27, 2018 04:37

Yeah you're right, wonderful things to turn the head inside out. :-D
I'll be back soon

Form is loading...

free blog software – This forum is powered by b2evolution CMS, a complete engine for your website.