Conflicting Javascript
PermalinkI've got a problem on one page of my site which means I can't edit anything in edit mode, and the c5 header is missing.
I've looked at other posts on the same subject and I've fixed this when I've had similar problem in the past, but this time it's proving difficult!
I've got the following js code:
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.10.custom.min.js"></script> <script type="text/javascript" src="js/bgstretcher.js"></script> <script type="text/javascript" src="js/main.js"></script> <script type="text/javascript"> $(document).ready(function(){ // Initialize Backgound Stretcher $('BODY').bgStretcher({ images: ['images/hp_bg1.jpg', 'images/hp_bg2.jpg' ], imageWidth: 2000, imageHeight: 1441, slideDirection: 'N', slideShowSpeed: 1000, transitionEffect: 'fade', sequenceMode: 'normal',
I've also tried removing these lines:
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="js/jquery-ui-1.8.10.custom.min.js"></script>
Any ideas why this might be?
Thanks
Lou
Many thanks
Of course. :) It's simple.
<?php if(!$c->isEditMode()){ ?> <script type="text/javascript" src="js/bgstretcher.js"></script> <script type="text/javascript" src="js/main.js"></script> <script type="text/javascript"> $(document).ready(function(){ // Initialize Backgound Stretcher $('BODY').bgStretcher({ images: ['images/hp_bg1.jpg', 'images/hp_bg2.jpg' ], imageWidth: 2000, imageHeight: 1441, slideDirection: 'N', slideShowSpeed: 1000, transitionEffect: 'fade', sequenceMode: 'normal', anchoring: 'left top',
The isEditMode() returns true if you're in edit mode. This is great for tweaking CSS (or turning of jQuery) while in edit mode. I usually use it to add an "edit-mode" CSS class to the body so I can tweak CSS for functionality purpose. :)
Just like mnakalay said, C5 already has the core files for jQuery so you don't have to include them.
Let me know how it turns out!
Thanks for the code, I added it to my site however it seemed to turn off the javascript even when viewing the live site.
Any ideas why?
Many thanks!
<?php if(!$c->isEditMode()){ ?>
...with....
<?php if($c->isEditMode()){ ?>
Sorry!! Coffee wasn't in my system yet.
Have I missed something obvious?
Thanks
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <?php Loader::element('header_required'); $html = Loader::helper('html'); ?> <link type="text/css" href="<?=$this->getThemePath()?>/style.css" rel="stylesheet" /> <link type="text/css" href="<?=$this->getThemePath()?>/typography.css" rel="stylesheet" /> <link type="text/css" href="<?=$this->getThemePath()?>/jquery-ui-1.8.10.custom.css" rel="stylesheet" /> <meta name="viewport" content="initial-scale=1.0, width=device-width" /> <?php if($c->isEditMode()){ ?> <script src="<?=$this->getThemePath()?>/js/jquery-ui-1.8.10.custom.min.js" type="text/javascript"></script> <script src="<?=$this->getThemePath()?>/js/bgstretcher.js" type="text/javascript"></script>
But I have no idea why!?
Thanks for all your help... and patience! ;)
Can you mark one of my answers as the "Best answer" maybe?
Have a great day!
Thanks :)
Do you have a live address we could check out?
That jquery line seems like it shouldn't be there indeed but if you already tried to remove it and it didn't change anything the problem must go deeper.