22972 Posts in 11596 Topics by 2824 members
|Go to End|
19 November 2011 at 10:42am
I have a page which is breaking on this function:
panel = $($(this).attr('href'));
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.
20 November 2011 at 1:46am
try this in init() of Page_Controller
20 November 2011 at 8:08am
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.
20 November 2011 at 9:00am
Thank, I have single quotes: $($(this).attr('href'));
Any other thoughts?
20 November 2011 at 9:01am
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.
|Go to Top|