Hey,
I tried to add a script (http://www.ajaxblender.com/bgstretcher-jquery-stretch-background-plugin....) to my zen subtheme.
- I copied the file bgstretcher.js in the js file in my subtheme's directory
- I added : scripts[] = js/bgstretcher.js in my subtheme's .info file
- I added the script in the head in my page.tpl.php (copied in /template in my subtheme directory):
Everything seems to be ok in my code : the script apperas in the list of the scripts called when the page is loaded.
But I d'ont have any
I tried to read other issues about adding script in page.tpl.php, talking about drupal_add_js, but I don't think it is related to my issue because with the .info I can call the scripts. Am I wrong ? I think I forgot or misunderstand something.
Can somebody help me.
Thank you.
Comments
Comment #1
akalata commentedHave you had any luck? Everything you've posted should work. I haven't used that script, but I've called others (superfish, cufon) in the same manner. One suggestion would be to use an absolute path to your image:
images: ['/sites/all/themes/mythemename/images/myimage.jpg'](note the first "/").Comment #2
cato commentedI have to agree on this issue, my zen subtheme isn't loading added scripts[] either.
I've added a line that reads
scripts[] = js/external.jsand it simply does not load. There is no errror in the file location, watching the apache log there is no mention of external.js anywhere.I'm running jquery-ui, jquery-update, admin_menu and a few other modules that could be suspected of tampering with the $scripts variable so the question is if this is a zen issue or if it's actually one of the other modules resetting and overwriting $scripts. I'm not sure.
Scripts from other modules _are_ being loaded though. I guess I'll revert back to including the script in page.tpl.php manually until we have a fix or some more info on this issue.
Thanks,
Christopher Cato
www.christophercato.se
Comment #3
akalata commented@cato - have you rebuilt your theme registry?
Comment #4
cato commentedYes, I've rebuilt theme registry and cleared all caches about a million times. To no effect :/
If there is a test I could run, I'll run it - just give me something to work with.
//Christopher
Comment #5
n8tronSo scripts are in the js folder, right?
And .info reflects the correct filename of scripts?
scripts[] = js/bgstretcher.js
scripts[] = js/scripts.js
bgStretcher path to image is correct and works in location bar?
Put js/scripts.js
Maybe try console.log() to test?
Comment #6
shruti.sheth commentedComment #7
r8r8r commentedI am actually on zen 7.x-3.0, but this seems to be the same issue.
I agree, there is a problem with js in Zen subthemes, more specific, with jQuery.
I have included
scripts[] = js/ws-script.jsin the .info file.
Its content:
Sure enough, I get a js-alertbox telling me
but not more.
The console throws the following error:
Replacing the code block above with the full jQuery syntax
results in both desired js-alertboxes:
Conclusion:
The jQuery shortcut $ is not handled correctly (or "as expected") in subtheme js files. I have not tracked down the reason for this, but maybe someone could do that or post a resolution. In the meantime, avoid using the $-shortcut and read http://wbsl.at/Su for some more information on alternatives and the underlying jQuery behavior.
Comment #8
akalata commented@r8r8r: The jQuery namespace change was actually made in core and has nothing to do with Zen. See http://drupal.org/update/modules/6/7#javascript_compatibility
Comment #9
barrapontoi guess we're done here.
Comment #10
Gik000 commentedThan?
Do we have to use always "JQuery" instead of "$" in declaration and so on...?
Comment #11
barraponto@Gik000 See http://drupal.org/node/171213