2013-03-16 118 views
1

在回发中维护基础选项卡状态的最佳方式是什么?最好是一种不使用cookies的方式。Zurb-Foundation维护选项卡状态

<dl class="tabs"> 
    <dd class="active"><a href="#simple1">Simple Tab 1</a></dd> 
    <dd><a href="#simple2">Simple Tab 2</a></dd> 
    <dd class="hide-for-small"><a href="#simple3">Simple Tab 3</a></dd> 
</dl> 
<ul class="tabs-content"> 
    <li class="active" id="simple1Tab">This is simple tab 1s content. Pretty neat, huh?</li> 
    <li id="simple2Tab">This is simple tab 2s content. Now you see it!</li> 
    <li id="simple3Tab">This is simple tab 3s content.</li> 
</ul> 

回答

1

这可能不是最好的解决方案,但它适用于我的.Net项目,也许它可以为你工作。

<asp:HiddenField runat="server" ID="currentTab" Value="0" /> 

$(document).ready(function() { 
    var tb = $(this).find("input[id*='currentTab']").val(); 
    if (tb == null) { 
     tb = 0; 
    } 
    if (tb == 1) { 
     //alert("Tab 1"); 
     tabName = "t4" 
     window.location.hash = tabName; 
     return false 
    } 
    if (tb == 2) { 
     //alert("Tab 2"); 
     tabName = "t2" 
     window.location.hash = tabName; 
     return false 
    } 
    if (tb == 3) { 
     //alert("Tab 3"); 
     tabName = "t3" 
     window.location.hash = tabName; 
     return false; 
    } 
}); 

Protected Sub Button_Click1(sender As Object, e As EventArgs) Handles Button.Click 
currentTab.Value = "3" 
End Sub