PDA

View Full Version : رفرش اجباری صفحه



ARIARAD
دوشنبه 12 خرداد 1393, 03:58 صبح
سلام وقته همگی بخیر

پیشاپیش برای نام تاپیک معذرت میخوام چون نمیدونستم واقعا اسمشو چی بذارم

من یه مشکلی دارم اونم اینه که یه سری تب های تو در تو ایجاد کردم توسط جاوااسکریپت که وقتی رو لینک تب کلیک شد ادرس صفحرو تغیر میده به این شکل
www.domain.com/#id-div (http://www.domain.com/#id-div) و div با ای دی مورد نظرو نمایش میده

به خوبی هم کار می کنه فقط یه مشکل دارم اونم اینه که وقتی از تب های تو در تو استفاده می کنم یعنی یه سری تب رو توی div تب های دیگه قرار بدم تو پیمایش بین تب های داخلی مشکل داره
لینکو تغیر میده ولی div تب مورد نظرو برام نمایش نمیده و وقتی که ادرس تغیر کرد صفحرو رفرش کنم اون div رو که می خوام نمایش میده یا از open new tab مرورگر استفاده می کنم عمل می کنه ولی بدون بارگذاری صفحه عمل نمی کنه

کد های جاوا اسکریپت تب هارو میذارم اگه امکانش هست که کدو تغیرش داد و مشکلو حل کرئ که عالی میشه
اگه نه یه کدی بهم پیشنهاد بدید که بعد از تغیر یو ار ال صفحرو رفرش کنه یا یه همچین چیزی

/*--------------------------------- Tabs
-----------------------------------*/
// tab setup
$('.tab-content').addClass('clearfix').not(':first').hide( );
$('ul.tabs').each(function(){
var current = $(this).find('li.current');
if(current.length < 1) { $(this).find('li:first').addClass('current'); }
current = $(this).find('li.current a').attr('href');
$(current).show();
});


// tab click
$(document).on('click', 'ul.tabs a[href^="#"]', function(e){
e.preventDefault();
var tabs = $(this).parents('ul.tabs').find('li');
var tab_next = $(this).attr('href');
var tab_current = tabs.filter('.current').find('a').attr('href');
$(tab_current).hide();
tabs.removeClass('current');
$(this).parent().addClass('current');
$(tab_next).show();
history.pushState( null, null, window.location.search + $(this).attr('href') );
return false;
});


// tab hashtag identification and auto-focus
var wantedTag = window.location.hash;
if (wantedTag != "")
{
// This code can and does fail, hard, killing the entire app.
// Esp. when used with the jQuery.Address project.
try {
var allTabs = $("ul.tabs a[href^=" + wantedTag + "]").parents('ul.tabs').find('li');
var defaultTab = allTabs.filter('.current').find('a').attr('href');
$(defaultTab).hide();
allTabs.removeClass('current');
$("ul.tabs a[href^=" + wantedTag + "]").parent().addClass('current');
$("#" + wantedTag.replace('#','')).show();
} catch(e) {
// I have no idea what to do here, so I'm leaving this for the maintainer.
}
}