我有一个 jQuery Accordion 定义如下:
$("#acrd").accordion({
autoHeight: false,
header: '.navhead',
alwaysOpen: true,
navigation: true,
collapsible: true,
disabled: true
});
当客户点击一个按钮时,我调用函数 DoSomething()
,如下所示:
function DoSomething(id) {
$.ajax({
url: "getapage.php?id="+id,
cache: false
}).done(function( html ) {
if(html == 'OK') {
$("#acrd").accordion({ active: 1 }); // doesn't work
} else {
alert("Give an error!");
}
});
}
但是当我点击按钮时没有任何反应,我检查了 Firebug 并且没有语法错误。
我怎样才能做到这一点? (进程中不开启 Accordion ,客户端一定不能改变 Accordion 的激活状态)
最佳答案
您可能打算使用 activate
方法,激活指定的内容部分:
$("#acrd").accordion("activate", 1);
但是,当 Accordion 被禁用时,这将不起作用。所以你需要把它写成
$("#acrd").accordion("enable").accordion("activate", 1).accordion("disable");
关于javascript - 如何保持 jQuery Accordion 禁用但仍更改其事件状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10613897/