Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-09-2011, 04:53 AM   PM User | #1
JessiBo
New to the CF scene

 
Join Date: Feb 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
JessiBo is an unknown quantity at this point
Unhappy jquery sliding panel menu problem

There is a simple solution to this, I however have not been able to execute it correctly.

I have a top level navigation (that is dynamically populated) that when clicked reveals a hidden panel. This works. The problem is when another menu item is clicked, that panel is stacked on any panels that are already open. How do I close any open panels first before opening another one.

Below is my code:

Code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".page-item-4").click(function(){
$("#slide-panel-photo").slideToggle("slow");
});
$(".page-item-6").click(function(){
$("#slide-panel-video").slideToggle("slow");
});
});
</script>
You can see the (barely there) work in progress here http://www.jessicabo.com/max01/

Any help is greatly appreciated
JessiBo is offline   Reply With Quote
Old 02-10-2011, 07:34 PM   PM User | #2
SB65
Senior Coder

 
Join Date: Feb 2009
Location: West Yorkshire
Posts: 2,812
Thanks: 9
Thanked 681 Times in 675 Posts
SB65 will become famous soon enoughSB65 will become famous soon enough
You could add an additional couple of lines to hide the other panel, and use the callback on the hide to call the slideToggle:

Code:
$(document).ready(function(){
$(".page-item-4").click(function(){
	$("#slide-panel-video").slideUp('slow',function(){
		$("#slide-panel-photo").slideToggle("slow");
	});
});
$(".page-item-6").click(function(){
	$("#slide-panel-photo").slideUp('slow',function(){
		$("#slide-panel-video").slideToggle("slow");
	});
});
});
This is OK if you've just got a couple of panels, as now, but will quickly get tedious with any more.

If you do intend to have more than one I'd redo your html so that the lists within the sidepanel are nested within the top level lists - so it becomes more like a standard drop down menu, then add some jQuery for the animation - it'll take a bit more effort initially but might be easier in the long term.
SB65 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:38 PM.


Advertisement
Log in to turn off these ads.