Reputation: 5476
I have a jQuery accordion defined like:
$("#acrd").accordion({
autoHeight: false,
header: '.navhead',
alwaysOpen: true,
navigation: true,
collapsible: true,
disabled: true
});
When a client clicks on a button, I call a function DoSomething()
, like this:
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!");
}
});
}
But nothing happens when I click the button, I checked Firebug and there is no syntax error.
How can I accomplish this? (without enabling the accordion in the process, the client must not be able to change the accordion active state)
Upvotes: 1
Views: 373
Reputation: 464
If you want it permanently disabled, then this might be useful for you
$("#accordion h3").unbind("click");
Replace h3 with whatever element you are using as a clickable header. You can still change the tabs by activate method or by setting active option.
Soruce: jQuery accordion: prevent pane from opening/cancel changestart event
Upvotes: 0
Reputation: 437386
You probably meant to use the activate
method, which activates the specified content part:
$("#acrd").accordion("activate", 1);
However, that won't work while the accordion is disabled. So you need to write it as
$("#acrd").accordion("enable").accordion("activate", 1).accordion("disable");
Upvotes: 2
Reputation: 15861
some thing like this , as document says Get or set the active option, after init.
like this jquery ui active
$( "#acrd" ).accordion( "option", "active", 2 );
Upvotes: 0
Reputation: 3535
Initialize a accordion with the active option specified.
$( "#acrd" ).accordion({ active: 2 , others.... });
then try your code...
Upvotes: 0