Zurb-Foundation维护选项卡状态 [英] Zurb-Foundation Maintain Tab State

查看:68
本文介绍了Zurb-Foundation维护选项卡状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在回发中维护基金会"选项卡状态的最佳方法是什么?最好是不使用Cookie的方式.

What's the best way to maintain the state of a Foundation tab on postback? Preferably a way that doesn't use cookies.

<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>

推荐答案

这可能不是最佳解决方案,但它适用于我的.Net项目,也许可以为您使用.

This may not be the best solution but it works for my .Net project, maybe it could work for you.

<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

这篇关于Zurb-Foundation维护选项卡状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆