jquery accordion: activate option using Struts <sj:accordion>

馋奶兔 提交于 2020-01-07 04:46:08

问题


I have a Struts 2 application that is utilizing 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.


回答1:


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!



来源:https://stackoverflow.com/questions/6105483/jquery-accordion-activate-option-using-struts-sjaccordion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!