jquery issue (with cycle plugin), scripts are only running in page footer

Permalink
I have the problem that my the cycle plugin (with some other scripts) are just work in the page footer.

When I add my scrips in the head of my template
<script src="<?php echo $this->getThemePath();?>/js/jquery-1.8.2.min.js"></script>
<script src="<?php echo $this->getThemePath();?>/js/jquery.cookie.js"></script>
<script src="<?php echo $this->getThemePath();?>/js/jquery.easing.1.3.js"></script>
<script src="<?php echo $this->getThemePath();?>/js/jquery.cycle.all.js"></script>
<script src="<?php echo $this->getThemePath();?>/js/jquery.actions.js"></script>

(jquery.actions.js contains my functions)

they don’t work.

When I put them, without jquery-1.8.2.min.js in the footer it works.
For me this is just a workaround and not a good coding. I like the scrips in the html head!

What’s going wrong?

 
JohntheFish replied on at Permalink Reply
JohntheFish
C5 has its own copy of jQuery (I think currently 1.7.2). You should load that using addHeaderItem. For an example, have a look at the code in the load jquery ui addon.

Loading any version of jQuery from anywhere other than c5's own version will result in conflicts when c5 needs to load jQuery.

Your header/footer issue could be compounded if you are not initialising your own script in a ready event handler.

PS. Generally, unless they really need to be in a header, putting scripts in the footer gives faster loading time and hence many will advise it for better ranking.
finegermandesign replied on at Permalink Best Answer Reply
Thanks, but I need some more help with this.

You mean:
$this->addHeaderItem($html->javascript("jquery.js"));

or
<?php echo $this->addHeaderItem($html->javascript("jquery.js"));?>

But how an where ?

And "Your header/footer issue could be compounded if you are not initialising your own script in a ready event handler."
Again what can I do ;-) ?

Thanks
JohntheFish replied on at Permalink Reply
JohntheFish
Both of the uses of add header item you have described are correct. The difference is the context of the php.

For jQuery, wrap your code that initialises the cycle plugin in:
$(document).ready(function(){
  // your code to call the cycle plugin
});
finegermandesign replied on at Permalink Reply
$(document).ready(function(){
I already have…