Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

How do I (correctly) include the jQuery code (or plugins for that matter)


Go to End


3 Posts   4635 Views

Avatar
thepurpleblob

Community Member, 28 Posts

21 February 2011 at 8:41am

If I want to use jQuery, am I responsible for downloading it myself and placing it in my mysite/javascript directory or does SilverStripe do anything cleverer than that? I wondered why jQuery was particularly recommended if there wasn't any specific support for it.

Avatar
Willr

Forum Moderator, 5523 Posts

21 February 2011 at 9:21am

Edited: 21/02/2011 9:22am

I wondered why jQuery was particularly recommended if there wasn't any specific support for it.

jQuery is recommended since a lot of the modules include jQuery (userforms, forum are 2 that I know..) so if you plan on using any modules it's likely it'll include jQuery if it has any front end javascript.

You are responsible for putting your plugins in the mysite folder but take a look first at sapphire/thirdparty. It has a bundle of plugins for jQuery that are used in the CMS so you can include those if you want.

Use <% require javascript(mysite/javascript/plugin.js %> to include plugin JS. Docs: http://doc.silverstripe.org/sapphire/en/reference/requirements

Avatar
thepurpleblob

Community Member, 28 Posts

21 February 2011 at 9:32am

Ah... that makes sense. Thanks!

I didn't know about the thirdparty directory at all.

I downloaded the latest jQuery into a folder in mysite and it all works nicely using 'requirements', so I am happy :)