Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to disable certain links of jquery accordion

I am currently implemented a jquery based accordion on a navigation section, but some parts of the navigation don't need to be part of the accordion (if there are no categories etc) i am just wondering if it is possible to disable parts of the accordion or not ?

i get the feeling this could be impossible but this site has surprised me before :)

Thanks very much.

like image 696
David Avatar asked Nov 27 '09 11:11

David


1 Answers

Previous trick does not work because of the binding order of events, but the following works:

// Add the class ui-state-disabled to the headers that you want disabled
$( ".whatyouwant" ).addClass("ui-state-disabled");

// Now the hack to implement the disabling functionality
var accordion = $( "#accordion" ).data("accordion");

accordion._std_clickHandler = accordion._clickHandler;

accordion._clickHandler = function( event, target ) {
    var clicked = $( event.currentTarget || target );
    if (! clicked.hasClass("ui-state-disabled")) {
        this._std_clickHandler(event, target);
    }
};

Whenever you want to activate a tab, do:

// Remove the class ui-state-disabled to the headers that you want to enable
$( ".whatyouwant" ).removeClass("ui-state-disabled");

That's it

like image 68
Untelp Avatar answered Sep 28 '22 07:09

Untelp