Jump to content

Recommended Posts

Posted

Hello,

i am trying to solve one issue from 2 days but no luck. 

i am developing one project in PW and its working perfect as always but issue is in footer file i am using one JS file as bellow

<script src="<?php echo $config->urls->templates?>assets/js/script.js"></script>

file load but script.js use few other files as bellow

include('js/jquery.easing.1.3.js');

these files are not loading , i have copied the JS folder in root and Home page start working but when i goto sub pages JS again stop working.

issue is with JS path.

how to fix that ?

Thanks

Posted

There's no include() function in javascript. This is what you want:

<script src="<?php echo $config->urls->templates?>assets/js/jquery.easing.1.3.js"></script>
<script src="<?php echo $config->urls->templates?>assets/js/script.js"></script>
Posted

Thanks diogo, 

but my issue is there is many JS files loading in each other and its simply not possible to add each file. is there way to load JS file from root or some JS function to get application root path?

Thanks

Posted

Hello

yes i saw this function which is loading javascript files

function include(scriptUrl) {
    document.write('<script src="' + scriptUrl + '"></script>');
}

and after in same JS file called files like this

include('js/jquery.easing.1.3.js');

how to add assets path in JS file ?

Thanks

 
 
Posted

Hello LostKobrakai,

thanks for reply but its not working. i think site/templates/  is not proper path.

but if i change this line as bellow it start working

document.write('<script src="localhost/site' + scriptUrl + '"></script>');

Thanks

Posted

You shouldn't hardcode the domain part of the url (localhost) or your site will break as soon as you move the site to another location (online). And the right path surely depends on where your js files are actually stored. 

Posted

What happens if you add "/" in front of "site" in LostKorbakai's code?

document.write('<script src="/site/templates/' + scriptUrl + '"></script>');

This will make the path start from web root. If your PW is in a subfolder, use "/subfolder/site/.....".

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...