2 Replies - 1492 Views - Last Post: 02 February 2010 - 02:36 PM

#1 Alex Fraiser  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 19-October 08

Any link clicked closes accordion

Post icon  Posted 19 October 2009 - 01:17 PM

Hey guys,

I am building an accordion for my blog and everything works fine except for one little thing. Whenever I put a link into one of the boxes, the accordion slides back up instead of following through with the link. The only time I want this accordion to work is when .heading is clicked. Here is the jQuery code:

 $(document).ready(function() {
	$('.heading').click(function() {
		if($(this).parent().hasClass('current')) {
			$(this).siblings('ul').slideUp('slow',function() {
				$(this).parent().removeClass('current');
				$.scrollTo('#accordion',1000);
			});
		} else {
			$('ul#accordion li.current ul').slideUp('slow',function() {
				$(this).parent().removeClass('current');
			});
			$(this).siblings('ul').slideToggle('slow',function() {
				$(this).parent().toggleClass('current');
			});
			$.scrollTo('#accordion',1000);
		}
		return false;
	});
});



If it matters at all, I followed the [ulr=]http://net.tutsplus....rdion/]tutorial here at Nettuts[/URL], but they do not account for this issue!

If it helps at all, here is the HTML to go along with it:

	<ul id="accordion">
		<li id="rss">
			<a href="#rss" class="heading"><span class="title">Subscribe</span> <span class="icon"></span></a>
			<ul>
				<li>
					<!--- extra content --->
				</li>
			</ul>
		</li>
		<li id="newsletter">
			<!--- extra content --->
		</li>
		<li id="twitter">
			<a href="#twitter" class="heading"><span class="title">Twitter</span> <span class="icon"></span></a>
			<ul>
				<li>
					<p><a href="http://twitter.com/Blogussion/">Follow us now</a>!</p>
				</li>
			</ul>
		</li>
	</ul>



Really appreciate any help! You guys were quick to help me with my last problem and I can't tell you enough how much I appreciate it. :D

Is This A Good Question/Topic? 0
  • +

Replies To: Any link clicked closes accordion

#2 Wimpy  Icon User is offline

  • R.I.P. ( Really Intelligent Person, right? )
  • member icon

Reputation: 159
  • View blog
  • Posts: 1,038
  • Joined: 02-May 09

Re: Any link clicked closes accordion

Posted 20 October 2009 - 04:46 AM

Is the purpose of this whole thing to learn how to do it yourself? or do you just want it done? :) If you just want it done I would suggest you to use the already finished jquery ui accordion widget: http://jqueryui.com/demos/accordion/ :)
Was This Post Helpful? 0
  • +
  • -

#3 saosin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 02-February 10

Re: Any link clicked closes accordion

Posted 02 February 2010 - 02:36 PM

Any solution on this?

After searching for "ajax accordion" I decided to post here because
I'm having the exact same issue with the same nettuts tutorial here:
http://net.tutsplus....uery-accordion/

My accordion loads with all the drawers un-collapsed, where - like Alex - would like my page to load
a collapsed accordion where the user clicks the heading to open each "<ul>"

lemme know coders.. thx

This post has been edited by saosin: 03 February 2010 - 10:52 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1