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

[solved] Trailing slash and jQuery -

Go to End

5 Posts   4176 Views


Community Member, 47 Posts

11 December 2009 at 8:48pm

Edited: 14/12/2009 10:13am

I am still struggling to have jQuery work properly on my 2.3.3 installation. I have finally narrowed down the problem to a question
of "trailing slash" ("/") at the end of the URLs .

If I use the url :

it works fine. jQuery is defined and I can animate my page ( tabs animation)

But if I try to access the page as : or

jQuery is not defined (of course if I remove the trailing slash and reload , it works perfectly)

I am totally puzzled here ...
FYI: to relsove another problem with local anchors I have added
SSViewer::setOption('rewriteHashlinks', false);
to my config file, following the forum entry :

It seems that a lot of you are able to use jQuery so ...what am I missing??
Any pointer , help, ..etc ..will be highly appreciated as I am simply running out of ideas...



Community Member, 97 Posts

14 December 2009 at 9:41am

I'm no JQuery expert, but I imagine it's nothing to do with JQuery as such.

1. Aren't pages without the trailing slash redirecting to a page with a slash anyway?

2. Also, how are you making sure the JQuery library gets included in the page?

You've something like this in a the relevant page controller's init(), right?




Community Member, 47 Posts

14 December 2009 at 10:13am

Edited: 14/12/2009 8:03pm

Tobych: Thank you for your reply. The problem was actually due to the way our code looks for external resources (we use the
Google Ajax Librairies API). I did not write the patch for this. I know it had to do with the way we access jQuery :
<script src="" type="text/javascript"></script>
<script src="" type="text/javascript"></script>

The line above works for us.

For your info: I have had several (other) problems when using "Requirements" for my javascript files and it has been suggested by other members here to include js librairies directly in the template files. I run the 2.3.3 version of SS . Iy might also be that the problem did not exist in previous versions.


Community Member, 97 Posts

14 December 2009 at 10:19am

Edited: 14/12/2009 10:20am

Glad you solved the problem. Yes, including Javascript libraries can be a pain with SilverStripe, because a) by default the javascript is included at the end of <body> (for reasons of efficiency, as I understand it), and b) because it's not possible to choose per call to Requirements::javascript() whether the script should be included in the head or at the bottom of the body.

Trouble is though, Requirements::javascript() is pretty damn handy.

In a recent project I had success by throwing efficiency to the wind and calling this in my Page_Controller::init():




Community Member, 47 Posts

14 December 2009 at 11:03am

Thanks for the tip! I will try it. (I agree that a "working" Requirements is quite convenient! )