Results 1 to 7 of 7

Thread: Animated Collapsible DIV v2.01 travel repeatly?

  1. #1
    Join Date
    Jan 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Animated Collapsible DIV v2.01 travel repeatly?

    1) Script Title: Animated Collapsible DIV v2.01

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

    3) Describe problem:

    currently i am using following for a single DIV

    jQuery(document).ready(function(){
    animatedcollapse.addDiv('x_item_enquiry', 'fade=1');
    animatedcollapse.init();
    });

    so i want to know how to handle with multiple DIV with variable DIV pattern ID

    eg $('div[@id^=DIV_]').animatedcollapse.addDiv();

    can i assign all DIV with ID pattern DIV_xxx ?

    many thanks/Davis.
    Last edited by ywkyee; 01-14-2009 at 11:30 AM.

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

    Default

    There are several ways to do this. One would be to define an array of IDs corresponding to those of your collapsible DIVs, then loop through them to enable the script on them. For example:

    Code:
    var mydivs=['div1', 'anotherdiv', 'div3', 'catdiv']
    
    for (var i=0; i<mydivs.length; i++){
    	animatedcollapse.addDiv(mydivs[i],"fade=1")
    }
    animatedcollapse.init()
    DD Admin

  3. #3
    Join Date
    Jan 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hello,

    thanks for your quick reply.

    as my DIV html are generated dynamic, ie

    <div id="x_1"></div>
    <div id="x_22"></div>
    .....
    <div id="x_13"></div>

    and i only know the pattern x_?? , so can you show me if possible using jquery travel method? like kinda this sytnax $('div[@id^=x_]').animatedcollapse.addDiv(); is it support? so i can assign all DIV id with x_ wildcard ?

    many thanks.

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

    Default

    The script isn't actually a jQuery plugin, so you can't call addDiv() directly on a set of jQuery elements. However, that's easy to work around. Simply gather the elements you want to target using jQuery first, then loop through it and call animatedcollapse.addDiv() on each element. An example:

    Code:
    jQuery(document).ready(function($){
    	var $group=$('#jason, #kelly, #michael') //group of elements as a jQuery object
    	$group.each(function(i){
    		animatedcollapse.addDiv(this.id, 'fade=1,height=80px')
    	})
    	animatedcollapse.init()
    })
    DD Admin

  5. #5
    Join Date
    Jan 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hello,

    THANKS very much for your help.

    that is the way I am looking for.. as i am not much familiar with jquery.
    i want to "grep" a pattern of DIV id with x_div_ wildcard

    ev_enquiry = $('div[@id^=x_div_]');
    ev_enquiry.each( function(i) {
    animatedcollapse.addDiv(this.i, 'fade=1');

    can you tell how to pass the DIV id inside addDiv()? as this.i not work..

    thanks/Davis.

  6. #6
    Join Date
    Jan 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    previous problem are solved, so how can i change this post as solved status? thanks/Davis.

  7. #7
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    You can go to your first post in this thread, click then click Go Advanced and add the Resolved prefix to the thread title.

    Good luck!

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
  •