Results 1 to 3 of 3

Thread: Hide Groups Easily with Animated Collapse?

  1. #1
    Join Date
    May 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Hide Groups Easily with Animated Collapse?

    Animated Collapse

    http://www.dynamicdrive.com/dynamici...edcollapse.htm

    Is there a quick way to hide every div that belongs to a group without listing each one individually?

    for example:

    With a few more divs,
    Code:
    animatedcollapse.hide(['cat', 'dog', 'rabbit' ])
    will get a bit much quickly and would be much better achieved using something like:
    Code:
    animatedcollapse.hide(['pets' ])
    Or should I just add a class to the relevant divs and use a link to hide them without the animation?

    Thanks

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    There are a couple of threads that may help you:

    http://www.dynamicdrive.com/forums/s...ad.php?t=48782
    http://www.dynamicdrive.com/forums/s...ad.php?t=54044

    If they don't let me know.
    DD Admin

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Put this highlighted code on your page after the animatedcollapse.init() call from Step 1 on the demo page:

    Code:
    <script type="text/javascript">
    
    animatedcollapse.addDiv('jason', 'fade=1,height=80px')
    animatedcollapse.addDiv('kelly', 'fade=1,height=100px')
    animatedcollapse.addDiv('michael', 'fade=1,height=120px')
    
    animatedcollapse.addDiv('cat', 'fade=0,speed=400,group=pets')
    animatedcollapse.addDiv('dog', 'fade=0,speed=400,group=pets,persist=1,hide=1')
    animatedcollapse.addDiv('rabbit', 'fade=0,speed=400,group=pets,hide=1')
    
    animatedcollapse.ontoggle=function($, divobj, state){ //fires each time a DIV is expanded/contracted
    	//$: Access to jQuery
    	//divobj: DOM reference to DIV being expanded/ collapsed. Use "divobj.id" to get its ID
    	//state: "block" or "none", depending on state
    }
    
    animatedcollapse.init()
    
    animatedcollapse.hideGroup = function(groupName){
    	var ids = [];
    	for(var p in animatedcollapse.divholders){
    		if(animatedcollapse.divholders[p].getAttr('group') === groupName){
    			ids.push(p);
    		}
    	}
    	animatedcollapse.hide(ids);
    };
    
    </script>
    Now you can collapse any group by its group name, example:

    Code:
    <a href="javascript:animatedcollapse.hideGroup('pets')">Hide Pets</a>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •