tekgrl
asked on
Help with nested jQuery accordions
Hello.
I have a table (must be a table) where the row expands to reveal another row that also expands/collapses.
The problem is when I click on the sub-row to expand it the parent row collapses.
Here is my table:
...And here is the jQuery code:
Please help!
I have a table (must be a table) where the row expands to reveal another row that also expands/collapses.
The problem is when I click on the sub-row to expand it the parent row collapses.
Here is my table:
<tr class="accordion">
<td>
<span></span><div class="head">Header 1</div>
</td>
</tr>
<tr class="content">
<td colspan="12">
<table border="0" cellspacing="0" cellpadding="0" id="lit">
<!-- panel -->
<tr class="accordion">
<td>
<span></span><div class="head">Header 2</div>
</td>
</tr>
<tr class="content">
<td>Some content here</td>
</tr>
<!-- end panel -->
</table>
</td>
</tr>
<!-- end panel -->
...And here is the jQuery code:
$(document).ready(function() {
//syntax highlighter
hljs.tabReplace = ' ';
hljs.initHighlightingOnLoad();
//accordion
$('tr.accordion').accordion({
//defaultOpen: 'section1',
speed: 'fast',
animateOpen: function (elem, opts) { //replace the standard slideUp with custom function
elem.next().slideFadeToggle(opts.speed);
},
animateClose: function (elem, opts) { //replace the standard slideDown with custom function
elem.next().slideFadeToggle(opts.speed);
}
});
//custom animation for open/close
$.fn.slideFadeToggle = function(speed, easing, callback) {
return this.animate({opacity: 'toggle', height: 'toggle'}, speed, easing, callback);
};
});
Please help!
Will be good to see the site.
ASKER
There is no solution for my current code? I am showing you a VERY abridged version of what I have built. It will take me a long time to start over.
Hopefully someone out there can help me.
My code is attached.
my-accordion.zip
Hopefully someone out there can help me.
My code is attached.
my-accordion.zip
You have two solutions above. That is the only way - the jquery Accordion plugin is not designed for nested levels, that is why you have to declare a new accordion element with the parent Accordion.
Or use the other plugin
Or use the other plugin
ASKER
Hmmm, okay I'm game. How do I reclassify my nested accordion? I tried giving it a new name "accordion2" and duplicating the .js but that didn't do it.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I've requested that this question be closed as follows:
Accepted answer: 500 points for hielo's comment #a39284828
for the following reason:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Accepted answer: 500 points for hielo's comment #a39284828
for the following reason:
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
Well I gave a very simple answer - give the nested accordion a different class.
No messing about.
No messing about.
http://www.adipalaz.com/experiments/jquery/nested_accordion.html