How to implement jQuery

Permalink
Can you add jQuery into a HTML block? I am trying to use a plugin, which I have declared in the header. But where and how do you implement javascript exactly?

 
TheRealSean replied on at Permalink Reply
TheRealSean
jQuery is loaded by the core so is already included,

what is it you are trying to achieve with the jQuery.

I am on the understanding it will work inside a html block, but I tend to put it either within the header/footer or directly in a block.

If I am using a jQuery navigation plugin then I tend to put this in the footer on a document ready.

But if its for jQuery tabs then I place it within the block itself.
Ibatterbee82 replied on at Permalink Reply
I am trying to add a jQuery carousel. I will probably create a block for this at some point, but for the mean time it would be useful to be able to add in jQuery into a HTML block for quickness.

I have tried copying and pasting javascript from a standard HTML document (which works) directly into a C5 HTML block, but it doesn't seem to work.

If I do add javascript into the header of footer, then would this need to be nested inside some PHP - and if so then how? Sorry, my PHP is very weak as I am still learning.

Thanks for the help so far
TheRealSean replied on at Permalink Reply 1 Attachment
TheRealSean
Attached is a carousel I included in a recent site, its been customised to fit my needs, and I can not promise it will work out of the box, as its a custom block that I have used tweaking an existing block so some of the functions are not needed in the controller.

If you look at the view.php you will see the bulk of the javascript there.

I get around the addToHeader by renaming the js file to view.js

Hope it helps,
Regards
Sean
Ibatterbee82 replied on at Permalink Reply
Thanks for this.

This still seems a little complicated, and being able to copy some simple javascript into a HTML block doesn't look promising. I'll have to continue playing around, but hopefully your coding will bring some inspiration.


Thanks