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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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


Go to End

2 Posts   620 Views


Community Member, 5 Posts

25 November 2012 at 7:51am

Hi guys,

I'd like to get custom jQuery working with my silverstripe install. I'm making a tenders class and want to do a bit of custom form field validation, but before I can do that I need to get the requires working and then my code inside the $(document).ready function working.

Here's what I have in my TenderHolder.php file

class TenderHolder_Controller extends Page_Controller {

public function init() {


Requirements::javascript ('mysite/javascript/jquery-latest.js');
Requirements::javascript ('mysite/javascript/test.js');



And here's what I have in my test.js file.

(function($) {
// your code here.

I've also tried this for the test.js file

$(document).ready(function() {

alert('hello world');


I know the requires are working because if I don't surround the alert in jQuery document ready tags then it'll make an alert appear.

Any ideas would be great appreciated!



Community Member, 23 Posts

4 December 2012 at 1:17am

I'm guessing that because it works without the jquery code, it's not loading jquery.

Requirements won't write the script tag in if the file doesn't exist so check the source, are there two <script> tags for your JS files near the bottom of the page?

If it is outputting them, check your JS console for errors, easily done with Web Developer in Firefox.

I always store JS files in themes/{name-of-theme} though I'm not sure if this was something I was told to do or just my preference. Can't see it would make a difference though.