jquery accordian hide show visible event trigger

I have coded a basic accordian which toggles elements in a form using next and previous buttons. The accordian is working as designed and does not require any editting. I am now required to fire a a function only once when a a designated accordian pane is displayed. The senario being that the trggered function should only fire once even if a user revisits that pane.

This has me slighlty confused about how to go about doing this using jquerys live event and or visible psuedocode.

Any direction.help would be gladly appreciated.

Answers


I don't know what your code looks like, but assuming you have some sort of callback for when a panel becomes active, with some sort of reference to a DOM node representing that panel, you could do something like this:

if(! $(panel).data('initialized') ) {
   // initialize panel
   $(panel).data('initialized', true);
}

I would use the accordionchange event, to bind to it you can do this

$('.ui-accordion').bind('accordionchange', function(event, ui) { alert('hello world'); });

Replace the selector $('.ui-accordion') with the unique path to the accordion you want to bind to.

Update to cater for the once only

In your method use

$('.ui-accordion').unbind('accordionchange'); 

to ensure it only fires once.


Need Your Help

$ne doesn't work with pymongo

python mongodb python-2.7 pymongo mongodb-query

my $ne : "" is not working properly with pymongo.

how to initialize the "min" variable properly?

c gcc initialization

I have a small problem in my code for finding the minimum value from a series of numbers. When I initialize min = 0, the minimum value turns out as 0. But when I don't initialize min, the answer is