Jquery only loads when logged in

Permalink
I am using C5's default theme. My jQuery dependent slideshow does not play unless I am logged in. When I'm not, Chrome dev tools show a reference error saying jQuery is not defined. I found no options in the dashboard that helped.

From what I read on here before, I know that I should not include jQuery myself since that would cause problems. In spite of that, I tried Google hosted jQuery into elements/header for when not in edit mode. No change to the problem, even on clearing the cache.

<?php  if (!$c->isEditMode()) { ?>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<?php  } ?>


Why does jQuery only load when I am logged in? I want it to always load.

zyrolasting
 
nickratering replied on at Permalink Reply
nickratering
If you want to load jQuery from your theme, you'll need to enable it in your theme if NOT logged in, and vice versa in your header required.
See:http://www.concrete5.org/documentation/developers/system/performanc...

So eventaully you'll use the google hosted jQuery if not logged in and when logged in Concrete5's version.
PauloCarvalhoDesign replied on at Permalink Reply
PauloCarvalhoDesign
Hi,
You dont need to load jquery as its always loaded logged in or not.
You must have a conflict.
Have used firebug to debug it?
2BitMarv replied on at Permalink Reply
2BitMarv
AFAIK isEditMode() works if Page is open for editing. !isEditMode() works if page ist NOT open for editing BUT requires to be logged in. The next "level" above is the isLoggedIn() respectively !isLoggedIn() because BEFORE you can edit a page you HAVE TO be logged in, as you know. In any case you have to deal with the JQuery-nonconflict mode in your JQuery Scripts to avoid JS conflicts with the given JQuery from concrete5! most of my projects didn't ever need a seperate include, because the given JQuery fills out the most wanted needs.
berteldk replied on at Permalink Reply
I have this problem aswell - but using firebug etc. dont show any errors... only works when im logged in using linked jquery engine (like this: ( <script src="http://www.webadress.com/js/jquery-1.3.1.min.js"></script> ), if i remove it and rely on the one thats in c5 standard it wont work! I need to add a line so that jquery loads standard or?
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
You can add a line to your theme or block controller with addHeaderItem() - there are plenty of examples in the forums and howtos. By using this C5 will make sure you don't get duplicate loads.

Alternatively, you can use my Load jQuery.UI addon which will make sure both jQuery and jQueryUI are loaded.
http://www.concrete5.org/marketplace/addons/load-jquery-ui/...

This works nicely if all you are doing is pasting some jQuery into an html block.
berteldk replied on at Permalink Reply
Awesome! This worked perfect - i still feel im cheating, so i might need to figure out the right way anytime soon - but for now this will work! thanks a alot.

cheers
lanacoder replied on at Permalink Reply
lanacoder
There may be some condition in the if statement that may be preventing jQuery from loading - http://www.yogihosting.com/jquery-load/....