Hi—another question for you all from this relative noob, hope you don’t mind. I’m having issues getting Jquery show/hide to work for individual entries within a category group.
I am displaying a category group in a sidebar on a page as follows:
<div id="container">
{exp:channel:categories channel="ice-cream" id="ice-cream" class="ice-cream" orderby="alphabetical" parent_only="yes"}
<a href="http://{path=template_group/ice-cream}">{category_name}</a>
{/exp:channel:categories}
</div>This works great, except there’s one page where I want this sidebar list to display a list of links that just open/close individual div boxes (in the example below, the “showhidebox”) with more information about them, instead of going to their link. I’m trying to pull this information from the single individual entry that’s been published to each category group. I tried to set this up as follows:
<div id="container">
{exp:channel:categories channel="ice-cream" id="ice-cream" class="ice-cream" orderby="alphabetical" parent_only="yes"}
{if last_segment == 'relevant_page'}
<a href="#">{category_name}</a>
<div id="showhidebox">
{exp:channel:entries channel="ice-cream" orderby="alphabetical" limit="1" cat_limit="1" disable="member_data|pagination|trackbacks"}
{flavor}
{color}
{taste}
{/exp:channel:entries}
</div>
{/if}
{/exp:channel:categories}
</div>In my jQuery I have the simple:
$(document).ready(function() {
$("#container ul li").click(function(){
$('#showhidebox').slideToggle('fast');
});
});And I have display:none on the showhidebox in the CSS.
This works except that it only ever pulls in one set of entries—the same set of entries, no matter which link/category-group is clicked in the list. And when a link is clicked, it only ever displays the showhidebox div under the first <li> in the generated list.
Any thoughts about what I’m doing wrong here? Thanks!