2864 Posts in 732 Topics by 700 members
Template Questions
SilverStripe Forums » Template Questions » Stop Silverstripe from modifying href attributes
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 2477 Views |
-
Stop Silverstripe from modifying href attributes

28 October 2009 at 10:24pm Last edited: 28 October 2009 11:37pm
Hi there,
I've got a weird problem. When there's a <a href="#somethinghere"> tag present in the template, and visting a page with parameters in the url (i.e. /page/?foo=bar), SilverStripe adds the parameter part to the anchor tag. This in turn causes a javascript to break which is dependant on the content of the href part.
To show the example:
code on /page/
<a href="#tabs-1">
code on /page/?foo=bar
<a href="?foo=bar#tabs-1">
This behaviour causes Silverstripe to break the javascript and for some weird reason loads the templates TWICE! The #tabs-1 is part of the functionality of the jQuery UI Tabs addon.
Is there a way to stop SilverStripe from adding the parameter part to the <a href=""> ?
I already have
active to stop Silverstripe from adding slashes to url's.SSViewer::setOption('rewriteHashlinks', false);
Help is much appreciated!
Edit: I seem to know what happens now. It doesn't break the javascript, but causes it to think i'm loading content into the tabs via Ajax. Because of the added parameter to the href tag, it thinks it's another url instead of the id of the tab. And that it shouldn't do, unless I tell it to.
Edit 2: Seems this is a conflict of functionalites of JQUI Tabs and Silverstripe. Silverstripe uses the base tag, so it *needs* to add the $URLSegment of the page before the anchor to make it navigate correctly. Then the JS "detects" a page url instead of an anchortag so it then loads the corresponding page into the displayed tab.
Guess i need to alter the JS to let it respond to something else, like title="#tabs-1" i guess.
-
Re: Stop Silverstripe from modifying href attributes

2 November 2009 at 9:12am
> Then the JS "detects" a page url instead of an anchortag so it then loads the corresponding page into the displayed tab.
This is a but in JQuery UI Tabs, it doesn't take the <base> into account when auto-detecting URLs that are not pointing to the current page.
Sadly there is no way to disable remote tabs (see http://dev.jqueryui.com/ticket/3527). Perhaps try raising this again on http://dev.jqueryui.com/newticket ? I've tried to fix it a while ago, but its a bit tricky to wrangle all W3C allowed URLs with regular expressions etc.
-
Re: Stop Silverstripe from modifying href attributes

2 November 2009 at 10:38pm Last edited: 2 November 2009 10:40pm
Hey Ingo,
Thx for your reply, but i fixed it already. I used a custom jquery script to target the href attribute of those <a> elements to reset the attribute to the wanted setting and it worked
This is the script i made:
jQuery(document).ready( function(){
// Count till 3 for the 3 tabs
for(i=1;i<=3;i++){
// Target tabs and modify attribute
jQuery('#actierotator #acties li a.tabs-'+i).attr('href','#tabs-'+i);
}
});
This overrides the generated code and "corrects" the behaviour to what i want it to do.And if JS is disabled, it degrades gracefully.
-
Re: Stop Silverstripe from modifying href attributes

18 December 2009 at 8:56am
Ah good find Guilllaume! I was trying to patch this myself a while ago, its very annoying... lets hope jQuery UI 1.8 comes out soon ;) Hows things going in Stockholm?
-
Re: Stop Silverstripe from modifying href attributes

28 January 2010 at 1:23pm
Hi There,
I am having a problem with this as well where I will write out links such as <a href="$Link" title="Go to page $PageNum">$PageNum</a>
The problem is if there is a query string it is randomly appended to $Link or even inside some html content sections.
I can't find a common theme too as to when this happens versus when it doesn't happen as it doesn't do it to every link in the page just random ones.
Any idea how to have this stop or remove it manually with a function or on the template?
Thanks
Joe -
Re: Stop Silverstripe from modifying href attributes

5 May 2010 at 2:55pm
JQuery 1.8 not fix the error, you need change the js for fix it.
| 2477 Views | ||
|
Page:
1
|
Go to Top |



