Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

Controlling a dynamically created div

So I found this script:
http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm

It is pretty nice and it helps me with a static page where all the code is "pre-written".

Problem comes when I try to use the createElement function to create a div and a link that uses the animated collapse code to expand and collapse the recently created div.

Firebug shows all the right code, but the div simply doesn't respond.

PS. When I create the div element I also specify the "animatedcollapse.addDiv('xxx', 'fade=0,speed=400,group=yyyy)" javascript
0
robrodp
Asked:
robrodp
  • 5
  • 2
1 Solution
 
WabbitSeasonCommented:
The problem is that the script initializes some required variables in its init method. Try calling animatedcollapse.init(); again after you added and addDiv'ed the elements. Works here.
0
 
robrodpAuthor Commented:
Thanks a lot

There is some good news and some bad news. Good news is that the dynamically added div behaves properly, the bad is that now all the other divs are immediately closed when prompted to open. Is there any way to reset the init method and the call it instead of just calling it twice? Some sort of animatedcollapse.end();

Thanks, it's been very helpful

0
 
robrodpAuthor Commented:
It seems like I fixed it creating a new toggle function that detects if the div displayed or not and then it hides it or shows it accordingly. Will test! Thanks!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
robrodpAuthor Commented:
Would you happen to know why, when the new object is added the last clicked div automatically opens?
0
 
robrodpAuthor Commented:
I've fixed it by adding a hidden div that has a collapsible div that is opened before hitting the animatedcollapse.init();
0
 
WabbitSeasonCommented:
Getting kind of hacky :). I don't think the script was meant to work with runtime-added divs. Anyway, do you need anymore help?
0
 
robrodpAuthor Commented:
Nop, thank you!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now