Solved

Controlling a dynamically created div

Posted on 2010-08-23
7
316 Views
Last Modified: 2012-05-10
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
Comment
Question by:robrodp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 
LVL 3

Accepted Solution

by:
WabbitSeason earned 500 total points
ID: 33508762
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
 

Author Comment

by:robrodp
ID: 33514379
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
 

Author Comment

by:robrodp
ID: 33516074
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
Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

 

Author Comment

by:robrodp
ID: 33516319
Would you happen to know why, when the new object is added the last clicked div automatically opens?
0
 

Author Comment

by:robrodp
ID: 33516563
I've fixed it by adding a hidden div that has a collapsible div that is opened before hitting the animatedcollapse.init();
0
 
LVL 3

Expert Comment

by:WabbitSeason
ID: 33518663
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
 

Author Comment

by:robrodp
ID: 33526713
Nop, thank you!
0

Featured Post

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
Suggested Courses

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question