我想在更新面板中保留 jquery 手风琴菜单 的状态 。
我已经尝试了下面的代码,但默认情况下,在菜单内发生的所有回发上,它总是打开第一个菜单。
<asp:HiddenField ID="hfaccordion" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Menu ID="mnuTest" runat="server" Orientation="Horizontal"
onmenuitemclick="mnuTest_MenuItemClick">
<Items>
<asp:MenuItem Text="View 1" Value="0" Selected="True"></asp:MenuItem>
<asp:MenuItem Text="View 2" Value="1" ></asp:MenuItem>
<asp:MenuItem Text="View 3" Value="2"></asp:MenuItem>
</Items>
</asp:Menu>
<asp:MultiView ID="mvwTest" runat="server" ActiveViewIndex="0">
<asp:View ID="vwOne" runat="server">
<div id="accordion">
<h3><a href="#">Menu 1</a></h3>
<div>
Test 1
<asp:Button ID="Button1" runat="server" Text="Post" />
</div>
<h3><a href="#">Menu 2</a></h3>
<div>
Test 2
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>
</asp:DropDownList>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
var active = $('#<%= hfaccordion.ClientID %>').val();
var currentindex= 0;
if (active != '') {
currentindex = active;
}
$("#accordion").accordion(
{
change: function(event, ui) {
var i = $("#accordion").accordion("option", "active");
$('#<%= hfaccordion.ClientID %>').val(i);
}
}
);
$("#accordion").accordion("activate", parseInt(currentindex));
});
function pageLoad(){
$("#accordion").accordion(
{
change: function(event, ui) {
var i = $("#accordion").accordion("option", "active");
$('#<%= hfaccordion.ClientID %>').val(i);
}
}
);
//$("#accordion").accordion();
//var activeMenu = localStorage.getItem('am');
//$("#accordion").accordion( "activate" , parseInt(activeMenu));
}
</script>
</asp:View>
<asp:View ID="vwTwo" runat="server">
<div>
<p>view 2</p>
<asp:Button ID="Button2" runat="server" Text="Button" />
</div>
</asp:View>
<asp:View ID="vwThree" runat="server">
<div>
<p>view 3</p>
<asp:Button ID="Button3" runat="server" Text="Button" />
</div>
</asp:View>
</asp:MultiView>
</ContentTemplate>
</asp:UpdatePanel>
这很紧急。提前致谢...