21309 Posts in 5738 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2146 Views |
-
[solved] Trailing slash and jQuery -

11 December 2009 at 8:48pm Last edited: 14 December 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 :
http://www.mysite.com/agit works fine. jQuery is defined and I can animate my page ( tabs animation)
But if I try to access the page as :
http://www.mysite.com/ag/ or
http://www.mysite.com/ag/?flush=1jQuery 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 : http://www.silverstripe.org/general-questions/show/252254It 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...Thanks.
-
Re: [solved] Trailing slash and jQuery -

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?
Requirements::javascript("mysite/javascript/lib/jquery-1.3.2.js");
Toby
-
Re: [solved] Trailing slash and jQuery -

14 December 2009 at 10:13am Last edited: 14 December 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="http://ajax.googleapis.com/ajax/libs/jquery/1.3.1/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js" 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.
Regards.
Lise -
Re: [solved] Trailing slash and jQuery -

14 December 2009 at 10:19am Last edited: 14 December 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():
Requirements::set_write_js_to_body(false);
Toby
-
Re: [solved] Trailing slash and jQuery -

14 December 2009 at 11:03am
Thanks for the tip! I will try it. (I agree that a "working" Requirements is quite convenient! )
| 2146 Views | ||
|
Page:
1
|
Go to Top |

