Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Collapsible DIV Question

  1. #1
    Join Date
    Jul 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Collapsible DIV Question

    1) Script Title: Animated Collapsible DIV

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

    3) Describe problem: Just wondering if there is a way to modify this script so that the selected DIV loads open AND remembers the user-chosen position throughout every page? Thanks. I tried some modified code in another thread but could not get it working.

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

    Default

    By user-chosen position, I gather you mean the user chosen state of the DIV (whether expanded or collapsed)? If you've enabled the persistence feature, the user chosen state is already remembered, just not across pages. To make it across pages, find the line:

    Code:
    animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload")
    and remove the part in red.

    Also find the following line, and remove the part in red:

    Code:
    this.isExpanded=animatedcollapse.getCookie(uniquepageid+"-"+divId) //"yes" or "no", based on cookie value
    Then find the following line, and add to it the part in green:

    Code:
    document.cookie = name+"="+value+";path=/"
    That should make the persistence feature site wide. Just make sure to enable persistence, and also, to use the same ID (ie: id="mydiv") for the animated DIV that are the same across pages.
    Last edited by ddadmin; 07-31-2007 at 06:33 AM.

  3. #3
    Join Date
    Jul 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you, I will try this out as soon as possible. Great site by the way.

  4. #4
    Join Date
    Jul 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have just tried the script again. After changing the js code, the div does not seem to remember the user chosen state at all anymore. Any ideas?

    Thanks for the help.

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

    Default

    Ah yes, forgot about one another line. Find the following line, and remove the part in red:

    Code:
    this.isExpanded=animatedcollapse.getCookie(uniquepageid+"-"+divId) //"yes" or "no", based on cookie value

  6. #6
    Join Date
    Jul 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That worked fantastic! But, I have one more question. I can't seem to get the div to load open by default by using "block".. Any suggestions?

    Thanks again for the time.

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

    Default

    Did "block" work before the changes I posted above? Nothing above should affect the "block" feature in any way...

  8. #8
    Join Date
    Jul 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No, I could never get "block" working unless the enable persistence was set to false. I can't seem to use true and "block" at the same time?

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

    Default

    Quote Originally Posted by qkz View Post
    No, I could never get "block" working unless the enable persistence was set to false. I can't seem to use true and "block" at the same time?
    Ok, this looks like a bug of the script. Find the below line and add to it the part in red:

    Code:
    if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes"  || persistexpand && this.isExpanded=="")
    Do the same for the virtually identical line further down:

    Code:
    else if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" || persistexpand && this.isExpanded=="")
    Let me know if that fixes the problem.

  10. #10
    Join Date
    Jul 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by ddadmin View Post
    Ok, this looks like a bug of the script. Find the below line and add to it the part in red:

    Code:
    if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes"  || persistexpand && this.isExpanded=="")
    Do the same for the virtually identical line further down:

    Code:
    else if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" || persistexpand && this.isExpanded=="")
    Let me know if that fixes the problem.
    This did not change anything, the div still loads closed by default.

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
  •