Results 1 to 4 of 4

Thread: Animated Collapse - Help with show/hide multiple div's or group

  1. #1
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Red face Animated Collapse - Help with show/hide multiple div's or group

    1) Script Title: Animated Collapsible DIV v2.4

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...edcollapse.htm

    3) Describe problem: I'm doing a multiple animated div page where i'd like to have a simple image with rollover effect.

    The initial onclick would be a call to hide a specific group of id's. I have this working with the following:

    Code:
    <a href="javascript:animatedcollapse.show(unique_group_of_IDs)"><img src="sample_state1.png"></a>
    and to hide:

    Code:
    <a href="javascript:animatedcollapse.hide(unique_group_of_IDs)"><img src="sample_state2.png"></a>
    The "unique_group_of_IDs" is being created by an earlier thread on DD with the following:

    Code:
    Inside your for loop you can also store the ids of all the auto generated ids, then pass them into functions show() and hide(). For example:
    
    var divids=[]
    for (var x=1; x<=3; x++){
    animatedcollapse.addDiv('unique_group_of_IDs'+x, 'fade=0,height=210px')
    divids.push('unique_group_of_IDs'+x)
    }
    
    Then:
    
    <a href="javascript:animatedcollapse.show(divids)">Show all</a>
    So! The question is how can I have one image/image rollover and link a call to that js command and then swap to another image/image rollover and then toggle the unique id while staying on the same page? There is this option as shown on the main script page but it only works for one div and not for a group.
    Last edited by MEAR; 04-20-2010 at 03:51 PM.

  2. #2
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Or simply put,

    How can I have the following do multiple div toggles:

    Code:
    <a href="#" rel="toggle[MUTIPLE_DIV_ID]" data-openimage="images/dealdetail/close_on.png" data-closedimage="images/dealdetail/open_on.png"><img src="images/dealdetail/close_on.png" /></a>

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

    Default

    Sorry for the delay. If I understand you correctly, you want to create a single link that mass toggles the states of multiple DIVs when clicked on. If so, try adding the below script to the HEAD section of your page:

    Code:
    <script type="text/javascript">
    
    function masstoggle(link, dividsarr){
    var $div1=jQuery('#'+dividsarr[0])
    var img=jQuery(link).find('img:eq(0)').get(0)
    if ($div1.css('display')=="block"){ //collapse all?
    	animatedcollapse.hide(dividsarr)
    	img.src="expand.jpg"
    }
    else{ //expand all?
    	animatedcollapse.show(dividsarr)
    	img.src="collapse.jpg"
    }
    }
    
    </script>
    Change "expand.jpg" and "collapse.jpg" above to the paths of your own images. Then define a link that calls this function:

    Code:
    <a href="#" onClick="masstoggle(this, List_of_ids_array); return false"><img src="expand.jpg" /></a>
    Where "List_of_ids_array" is an array of IDs corrsponding to the DIVs you wish to expand/collapse all at once, for example:

    Code:
    <a href="#" onClick="masstoggle(this, ['jason', 'kelly', 'michael']); return false"><img src="expand.jpg" /></a>
    DD Admin

  4. The Following User Says Thank You to ddadmin For This Useful Post:

    MEAR (04-20-2010)

  5. #4
    Join Date
    Apr 2010
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Wow. That was is. 4 days of trying all sorts of work-arounds. I think that this should be part of the install option on the project page as well. But that's just me. Thanks so much for getting back to me and helping to end days of hellish noobishisness.

    Consider this thread RESOLVED.

    -M

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
  •