I’ve had some difficulty in the last couple of months adding jQuery in to my widget form in the admin area (for ThinkTwit), especially with adding functionality that will let me roll up a group of settings to make it easier for the user to edit them as there are so many. It turned out that this was due to objects being loaded after the page has loaded (see issue and solution).
Having got past this issue, I decided to remove the workaround that I had implemented and have another go at implementing an accordion. My initial thought was to use the jQuery accordion but I noticed on the API page that you can’t use it if you want more than one group open at a time. Instead I borrowed some alternative code from it and was able to implement it as below:
Of course, the first line after the script is getting a reference to your widget id – in this case it is used within the form() function but there are other ways to get it.
I hope this comes in use to someone as I know that people regularly land on my site looking in to adding jQuery in to their admin pages.