我正在尝试实施省电手风琴菜单......
到目前为止,我有这个:
$(document).ready(function () {
$("#accordionMenu").accordion({
alwaysOpen: false,
animated: true,
autoHeight: false,
collapsible: true,
icons: false,
navigation: true
});
var toOpen = <%= MySessionInfo.Current.MyMenu %>;
if(toOpen != -1){
alert("it should open: " +toOpen);
$("#accordionMenu").accordion("active", toOpen);
alert("active is : " + $("#accordionMenu").accordion("option", "active"));
}
$("#accordionMenu").click(function (){
var activate = $("#accordionMenu").accordion("option", "active");
if (activate != false) {
$.getJSON("/Account/SetMenu", { CurrentMenu: activate }, function (j) {});
}
});
});
它设置正确的索引并显示正确的消息“它应该打开X”,其中X是期望值。 但是,它不会保持打开该部分,并且在设置“活动”值后,“活动是:Y”始终显示“假”。
发生了什么事?
答案 0 :(得分:2)
你有一个错字。它应该是
$('...').accordion('activate', index);
答案 1 :(得分:1)
你应该这样做:
$("#accordionMenu").accordion({active:toOpen});
或
$("#accordionMenu").accordion("activate", toOpen);