I have the following tabs in jquery-tools:
<!-- tabs -->
<ul class="css-tabs">
<li><a href="/example/a">ABC</a></li>
<li><a href="/example/b">DEF</a></li>
</ul>
<!-- single pane. it is always visible -->
<div class="css-panes">
<div style="display:block"></div>
</div>
And I have history turned on.
So when I press on the first tab ABC, I have the url:
http://www.example.com/example/a#/example/a
And once the second tab DEF is clicked the url looks like this:
http://www.example.com/example/b#/example/b
I don’t like how the url looks like and I would prefer if the tab history was according to the name of the tab (ABC and DEF): http://www.example.com/example/a#ABC and http://www.example.com/example/b#DEF
I have been looking for this for quite a while but couldn’t find anything about how this can be done…
Ok, so I’m going to answer my own question >_<
No I didn’t find the solution somewhere on the net, I solved it myself…
The solution is for jquery-tools version 1.2.6 stable
In jquery-tools code which concerns the history tool, you change it from this:
To this: (no need for the new lines, you can remove them and return it to one line)
The changes are two simple changes:
This:
was changed to this:
And this:
was changed to this:
Also one more important thing, you need to add the attribute “name” to your tabs and put the name you want to appear in the address after the # (in my case I want the same link/name of the tab to appear), like this:
And that’s it you, now have a working jquery-tools’ tabs with history working with “#name of the tab” and not the “#href link” 😀
Like these:
http://www.example.com/example/a#ABC
http://www.example.com/example/b#DEF
If you don’t want the “name” attribute but the id or class, then change where I put name to id or class, but make sure to put id or class in your tabs too…