Current location: Hot Scripts Forums » General Web Coding » JavaScript » PLEASE help with adding a second Moo Accordion


PLEASE help with adding a second Moo Accordion

Reply
  #1 (permalink)  
Old 02-23-09, 05:26 AM
AshleyQuick AshleyQuick is offline
Newbie Coder
 
Join Date: May 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
PLEASE help with adding a second Moo Accordion

Code:
<script type="text/javascript">
	window.addEvent('domready', function() {

		//make the accordion
		var accordion = new Accordion($$('.toggler'),$$('.element'), {
			opacity: 0,
			onActive: function(toggler) { toggler.setStyle('color', '#0072BC'); },
			onBackground: function(toggler) { toggler.setStyle('color', '#222'); }
		});

		//make it open on hover
		$$('.toggler').addEvent('mouseenter', function() { this.fireEvent('click'); });


	});
	</script>
</head>
<body>

<div id="accordion">
<h4 class="toggler">Hover</h4>
<div class="element">
Content
</div>
</div>

This is the code for the first. I need to add another that is independent of this. Help?
Reply With Quote
  #2 (permalink)  
Old 02-23-09, 05:39 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
This maybe:

Code:
<script type="text/javascript">
	window.addEvent('domready', function() {

		//make the accordion
		var accordion = new Accordion($$('.toggler'),$$('.element'), {
			opacity: 0,
			onActive: function(toggler) { toggler.setStyle('color', '#0072BC'); },
			onBackground: function(toggler) { toggler.setStyle('color', '#222'); }
		});

		//make it open on hover
		$$('.toggler').addEvent('mouseenter', function() { this.fireEvent('click'); });


	});

window.addEvent('domready2', function() {

		//make the accordion
		var accordion2 = new Accordion($$('.toggler2'),$$('.element2'), {
			opacity: 0,
			onActive: function(toggler2) { toggler2.setStyle('color', '#0072BC'); },
			onBackground: function(toggler2) { toggler2.setStyle('color', '#222'); }
		});

		//make it open on hover
		$$('.toggler2').addEvent('mouseenter', function() { this.fireEvent('click'); });


	});
	</script>

</head>
<body>

<div id="accordion">
<h4 class="toggler">Hover</h4>
<div class="element">
<h4 class="toggler2">Hover2</h4>
<div class="element2">
Content
</div>
</div>
Even more sliders? Look here: http://www.programmingtalk.com/showthread.php?t=49138
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Reply With Quote
  #3 (permalink)  
Old 02-23-09, 06:12 AM
AshleyQuick AshleyQuick is offline
Newbie Coder
 
Join Date: May 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks. A minor tweak got it working but any idea how to make it close on mouseleave?

Code:
<script type="text/javascript">
window.addEvent('domready', function() {

	//make the accordion
	var accordion = new Accordion($$('.toggler'),$$('.element'), {
		opacity: 0,
		onActive: function(toggler) { toggler.setStyle('color', '#0072BC'); },
		onBackground: function(toggler) { toggler.setStyle('color', '#222'); }
	});

	//make it open on hover
	$$('.toggler').addEvent('mouseenter', function() { this.fireEvent('click'); });


});
window.addEvent('domready', function() {

	//make the accordion
	var MyAccordion = new Accordion($$('.MyAcctoggler'),$$('.MyAccelement'), {
		display: -1,
		opacity: 0,
		onActive: function(MyAcctoggler) { MyAcctoggler.setStyle('color', '#0072BC'); },
		onBackground: function(MyAcctoggler) { MyAcctoggler.setStyle('color', '#222'); }
	});

	//make it open on hover
	$$('.MyAcctoggler').addEvent('mouseenter', function() { this.fireEvent('click'); });


});
</script>
Reply With Quote
  #4 (permalink)  
Old 02-23-09, 06:40 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
If it closes when you click an opened one again you can do it like this I think. Got the openClose: true from the samples on the Moo website.:

Code:
<script type="text/javascript">
window.addEvent('domready', function() {

	//make the accordion
	var accordion = new Accordion($$('.toggler'),$$('.element'), {
		opacity: 0,
		onActive: function(toggler) { toggler.setStyle('color', '#0072BC'); },
		onBackground: function(toggler) { toggler.setStyle('color', '#222'); }
		openClose : true;
	});

	//make it open on hover
	$$('.toggler').addEvent('mouseenter', function() { this.fireEvent('click'); });
	//make it close on mouseleave
	$$('.toggler').addEvent('mouseleave', function() { this.fireEvent('click'); });

});
window.addEvent('domready', function() {

	//make the accordion
	var MyAccordion = new Accordion($$('.MyAcctoggler'),$$('.MyAccelement'), {
		display: -1,
		opacity: 0,
		onActive: function(MyAcctoggler) { MyAcctoggler.setStyle('color', '#0072BC'); },
		onBackground: function(MyAcctoggler) { MyAcctoggler.setStyle('color', '#222'); }
		openClose : true;
	});

	//make it open on hover
	$$('.MyAcctoggler').addEvent('mouseenter', function() { this.fireEvent('click'); 
	//make it close on mouseleave
	$$('.toggler').addEvent('mouseleave', function() { this.fireEvent('click'); });
});


});
</script>
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accordion Sliding to Screen Top on Open cesarcesar JavaScript 5 12-15-08 01:57 PM
MooTools Accordion Sliding Incorrectly cesarcesar JavaScript 1 11-04-08 04:08 AM
script timing out when adding entries to database Jay6390 PHP 4 04-24-07 08:47 PM
Adding to Record? tommyc325 Database 7 11-02-06 12:17 PM
Moo Productions MP User General Advertisements 0 01-14-06 11:05 PM


All times are GMT -5. The time now is 11:46 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.