我有一个MVC项目,它使用JQuery Accordion菜单进行导航。我想知道是否有任何方法可以修改菜单,以便当我点击其中一个链接时,菜单在导航到下一页时保持打开状态
jQuery -
$(document).ready(function () {
//ACCORDION BUTTON ACTION
$('div.accordionButton').click(function () {
//IF THE DIV YOU CLICKED IS ALREADY OPEN, CLOSE AND REMOVE THE OPEN CLASS
if ($(this).next().hasClass('openDiv')) {
$('div.accordionContent.openDiv').slideUp('normal');
$('div.accordionContent.openDiv').removeClass('openDiv');
}
//CLOSE ANY OPEN DIVS, OPEN THE CLICKED DIV
else {
$('div.accordionContent.openDiv').slideUp('normal');
$('div.accordionContent.openDiv').removeClass('openDiv');
$(this).next().slideDown('normal');
$(this).next().addClass('openDiv');
}
});
//HIDE THE DIVS ON PAGE LOAD
$("div.accordionContent").hide();
});
HTML -
@foreach (var sport in Model.SportTypesList)
{
<div id="wrapper">
<div class="accordionButton">@sport.ToString()</div>
<div class="accordionContent">
@foreach (var coupon in Model.CurrentCoupons())
{
if (coupon.SportID.ToString().Equals(sport.ToString()))
{
<div id="bullets">></div>
@Ajax.ActionLink(@coupon.CouponName, "Index", "Home", new { couponName = coupon.CouponName, sportName = coupon.SportID.ToString() }, new AjaxOptions
{
UpdateTargetId = "coupons",
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET"
})
<br />
}
}
</div>
</div>
}
答案 0 :(得分:0)
您可以在会话中输入您选择的标签的ID,然后从中检查ID并继续打开标签。一个简单的解决方案。