jquery accordion: activate option using Struts <sj:accordion>
I have a Struts 2 application that is util开发者_开发问答izing the accordion feature of the Struts2 jQuery plugin (http://code.google.com/p/struts2-jquery/wiki/AccordionTag) and I'm trying to programmatically traverse through the accordion items. What I mean is that I basically want to have a button in each accordion content area that opens up the next accordion item below it. Using plain jQuery outside of my Struts application, I seem to be able to do this: $("#accordion").accordion('activate', x);
, as described here: jQuery UI Accordion activate
When i try to do this with my struts jquery implementation, however, it screws up the rendering of my accordion altogether. Unfortunately, using plain jQuery UI doesn't seem to be an option for me. Is there any other possible way to do this with what I'm currently working with? Is it even possible to use jQuery to manipulate the accordion object that struts created?
Any help would be greatly appreciated. I really want to continue using the accordion in this fashion because it's very easy to use, but I'm not sure that it's flexible enough to suit my purposes.
Thanks in advance for any advice you can provide.
this is so awesome, i figured i would share with the world :)
All i had to do was add this code $("#accordion").accordion('activate', 0);
to an area below my sj:accordion object. My problem was that i was putting this code in the head of my document, but I'm assuming there is a difference in when the elements are rendered, therefore I can only reference this object after it's actually been created. Now I can bind the click event of buttons to open different accordion items. It's working like a charm!
精彩评论