-2
我正在使用opencart模板。這裏我試圖在div選項卡中顯示一些mysql表格數據。它工作正常。但是,當我重新加載瀏覽器時,它不顯示默認的當前div div數據。如果我點擊另一個標籤它顯示所有提交的數據正確opencart div選項卡內容不會在頁面加載時顯示
當我重新加載瀏覽器,它這樣表示
然後我點擊註釋選項卡,再單擊我的評價選項卡。我懂了。
爲什麼評論標籤內容不顯示在頁面加載?
<ul id="dashboard_tabs">
<?php if($description) { ?>
<li><a href="#one"><?php echo $tab_description; ?></a></li>
<?php } ?>
<?php if ($review_status) { ?>
<li><a href="#two" ><?php echo $tab_review; ?></a></li>
<?php } ?>
<?php if ($attribute_groups) { ?>
<li><a href="#three">Notes</a></li>
<?php } ?>
<?php if ($products) { ?>
<li><a href="#four" ><?php echo $tab_related; ?> <?php /*echo count($products);*/ ?></a></li>
<?php } ?>
</ul>
<div id="dashboard_content_details">
<div id="one">
<?php echo $description; ?>
</div>
<div id="two">
some contents
</div>
<div id="three">
some contents
</div>
<div id="four">
some contents
</div>
</div>
jQuery的
$(function(){
function resetTabs(){
$("#dashboard_content_details > div").hide(); //Hide all content
$("#dashboard_tabs a").attr("id",""); //Reset id's
}
var myUrl = window.location.href; //get URL
var myUrlTab = myUrl.substring(myUrl.indexOf("#")); // For localhost/tabs.html#tab2, myUrlTab = #tab2
var myUrlTabName = myUrlTab.substring(0,4); // For the above example, myUrlTabName = #tab
(function(){
$("#dashboard_content_details > div").hide(); // Initially hide all content
$("#dashboard_tabs li:first a").attr("id","current"); // Activate first tab
$("#dashboard_content_details > div:first").fadeIn(); // Show first tab content
$("#dashboard_tabs a").on("click",function(e) {
e.preventDefault();
if ($(this).attr("id") == "current"){ //detection for current tab
return
}
else{
resetTabs();
$(this).attr("id","current"); // Activate this
$($(this).attr('href')).fadeIn(); // Show content for current tab
}
});
})()
});
這是標籤的一些*自制*實現?爲什麼不使用OpenCart自帶的默認Jquery Tabs插件? – shadyyx