View Full Version : Animated Collapsible DIV: with AJAX?

08-07-2007, 08:16 AM
1) Script Title: Animated Collapsible DIV

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/animatedcollapse.htm

3) Describe problem:

The effect is awesome and crossbrowser with inline content, but when doing AJAX calls (in effect i'm using AHAH) in order to include dynamic content in the div, it doesn't slide to fit its *new* height.
If some inline content is still present within the div, AJAX content will correctly replace it, but the div height keeps standing on the original (inline calculated) value.

Is this somehow related to the 'dotask' function, that actually 'getheight' of 'thisobj' only 'onwindowload'?

animatedcollapse.dotask(window, function(){thisobj._getheight(persistexpand)}, "load")
I tried to use XMLHttpRequest/ActiveXObject(var req.onreadystatechange), even if getting javascript errors like 'req not defined' (since scripts are separated) i got some results:

the onClick (or whatever event you want for the button) activates AHAH before animatedcollapse, so the div height IS updated with the call, and the slide goes down correctly!
Bingo? Nay, because the hide switch won't slide up nothing, and i can't figure out where the key fault could reside... maybe in the line

else if (parseInt(this.divObj.style.height)==this.contentheight)
or in the persistence features?

I used to do AHAH calls only with slidedown or a modified slideit, in order to avoid unexpected height values while closing up, however it doesn't matter if trying with slideup too.