Kalau kita mau membuat tabs saat di reload tidak berubah posisi yang aktif, silahkan copas script berikut di tambahkan di head:
1).
$(function() {
var hashTab = location.hash.replace(/#for/, "#tabs");
var activeTab = 0;
if(hashTab.length > 0) {
activeTab = $('a[href^="#tabs-"]').index($('a[href="' + hashTab + '"]'));
}
// console.log(hashTab, activeTab)
hashLinks()
$("#tabs").tabs({
active: activeTab,
activate: function(event, ui) {
history.pushState({}, '', ui.newTab.find("[href]").prop("hash").replace(/#tabs/, "#for"));
hashLinks()
}
})
function hashLinks() {
$(".links a").prop("hash", location.hash.replace(/#tabs/, "#for"))
}
$("button").click(function() {
location.reload(true)
})
})
1).
$(function() {
var hashTab = location.hash.replace(/#for/, "#tabs");
var activeTab = 0;
if(hashTab.length > 0) {
activeTab = $('a[href^="#tabs-"]').index($('a[href="' + hashTab + '"]'));
}
// console.log(hashTab, activeTab)
hashLinks()
$("#tabs").tabs({
active: activeTab,
activate: function(event, ui) {
history.pushState({}, '', ui.newTab.find("[href]").prop("hash").replace(/#tabs/, "#for"));
hashLinks()
}
})
function hashLinks() {
$(".links a").prop("hash", location.hash.replace(/#tabs/, "#for"))
}
$("button").click(function() {
location.reload(true)
})
})
Tidak ada komentar:
Posting Komentar