Mam mały problem z zakładkami z tej strony
http://jqueryfordesigners.com/jquery-tabs/
Bardzo fanjny i prosty skrypt jquery, ale ma małą wadę. Po przełądowaniu strony nie zapamiętywało na której zakładce była ustawiona strona.
Ale znalazłem w komentarzach wersję która taką funkcję posiada:
Kod
$(function () {
var tabContainers = [];
$('ul.tabs a').each(function () {
// note that this only compares the pathname, not the entire url
// which actually may be required for a more terse solution.
if (this.pathname == window.location.pathname) {
tabs.push(this);
tabContainers.push($(this.hash).get(0));
}
});
// sniff for hash in url, and create filter search
var selected = window.location.hash ? '[hash=' + window.location.hash + ']' : ':first';
tabs.click(function () {
// hide all tabs
tabContainers.hide().filter(this.hash).show();
// set up the selected class
$(tabs).removeClass('selected');
$(this).addClass('selected');
return false;
}).filter(selected).click();
});
var tabContainers = [];
$('ul.tabs a').each(function () {
// note that this only compares the pathname, not the entire url
// which actually may be required for a more terse solution.
if (this.pathname == window.location.pathname) {
tabs.push(this);
tabContainers.push($(this.hash).get(0));
}
});
// sniff for hash in url, and create filter search
var selected = window.location.hash ? '[hash=' + window.location.hash + ']' : ':first';
tabs.click(function () {
// hide all tabs
tabContainers.hide().filter(this.hash).show();
// set up the selected class
$(tabs).removeClass('selected');
$(this).addClass('selected');
return false;
}).filter(selected).click();
});
Nie wiem dlaczego, ale teraz zakładki nie chcą się chować jedna pod drugą.
Poniżej podaje linki do skryptu orginalnego (tabs1) i z modyfikacją (tabs2)
Tabs1
http://dobry-katalog.cba.pl/x/tabs1.html
Tabs2
http://dobry-katalog.cba.pl/x/tabs2.html
Jak ktoś ma pomysł jak to naprawić to będę wdzięczny. Ja walcze z tym już kilka ładnych godzin i nie wpadłem na rozwiązanie.
A poniewąż js i jquery nie znam za bardzo to błądzę jak ślepy w ciemnościach.
Proszę o podpowiedz.