jquery 手风琴打开一个部分
我正在尝试实现一个状态保存手风琴菜单...
到目前为止我有这个:
$(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”始终显示“假”。
发生了什么事?
I'm trying to implement a state-saving accordion menu...
So far I have this:
$(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) {});
}
});
});
It sets the correct index and it shows the right message "it should open X", where X is the expected value.
However, it doesn't keeps open that section and after setting the "active" value, the "active is: Y" shows "false" all the time.
what's happening?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你有一个错字。它应该
位于 http://jqueryui.com/demos/accordion/#method-activate< /a>
You got a typo. It should be
Found at http://jqueryui.com/demos/accordion/#method-activate
您应该执行以下任一操作:
或
You should do either:
or