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

How do I suppress empty namespaces with FOR XML in Sql Server

sql-server xml namespaces for-xml

We are encountering a strange problem with SQL Server 2005/2008 using the FOR XML with fragments of xml and namespaces. Here is the query in question.

Controlling size / position of UINavigationItem titleView

iphone ios cocoa-touch uinavigationcontroller uinavigationbar

In my app, I have some custom titles (with lettering that isn't a font) stored in pngs that I want to put as the title of my navigation. I want the lettering in the titles all to be the same size for

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.