21300 Posts in 5735 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1071 Views |
-
JQuery conflict: unrecognized expression [ SOLVED ]

19 November 2011 at 10:42am
I have a page which is breaking on this function:
$(options.navigation).click(function() {
panel = $($(this).attr('href'));
$(window)._scrollable().stop();
$.scrollTo(panel, {
duration: 500,
easing: 'swing'
});HTML: <a href="#panel1" class="navigation" title="Panel 1">1</a>
It gives me "Syntax error, unrecognized expression: /" clicking on any navigation item, from the line "panel = $($(this).attr('href'));"
If I have the exact same HTML page outside of Silverstripe it works perfectly.
If I copy the file to say, http://localhost/dev.html and run this inside SilverStripe it's also fine.
But if I run it at http://localhost/dev/ it gives me the Syntax error again. Is is something to do with mod_rewrite? The script even works fine when I'm not running it via a server (just directly in the browser).
Any theories about what's going on here? I've been stuck on this bug for a couple of hours now, would be wonderful to know if there is a fix.
-
Re: JQuery conflict: unrecognized expression [ SOLVED ]

20 November 2011 at 1:46am
try this in init() of Page_Controller
Requirements::set_write_js_to_body(false);
-
Re: JQuery conflict: unrecognized expression [ SOLVED ]

20 November 2011 at 8:08am
Thanks, no luck I'm afraid. I've made sure all the javascript includes are not minified. Would love any other input.
-
Re: JQuery conflict: unrecognized expression [ SOLVED ]

20 November 2011 at 8:58am
SilverStripe is rewriting the link so that it includes the current URL so that the anchor link actually works. You can usually get around this by using single quotes around the href attribute instead of double quotes.
-
Re: JQuery conflict: unrecognized expression [ SOLVED ]

20 November 2011 at 9:00am
Thank, I have single quotes: $($(this).attr('href'));
Any other thoughts?
-
Re: JQuery conflict: unrecognized expression [ SOLVED ]

20 November 2011 at 9:01am
Not in the JavaScript, in the template.
-
Re: JQuery conflict: unrecognized expression [ SOLVED ]

20 November 2011 at 9:03am
Awesome, fixed! Thank you so much.
Changed:<a href="#panel1" class="navigation" title="Panel 1">1</a>
To: <a href='#panel1' class='navigation' title='Panel 1'>1</a>
Thanks, that's really great to know.
| 1071 Views | ||
|
Page:
1
|
Go to Top |


