View Full Version : Changing animateTarget in BasicDialog

27 Feb 2007, 9:18 AM
I have a situation where I need to change the animateTarget of a dialog after the dialog has been created. My function that brings up the dialog is something like this (this code is contrived for illustrative purposes):

this.showMyDialog = function(animateTarget) {
if (!this.dialog) {
this.dialog = new YAHOO.ext.BasicDialog('myEl',{...});
this.dialog.animateTarget = animateTarget;

Here's what's happening:
- User clicks LinkA, showMyDialog is called with LinkA as the single parameter (animation works)
- User closes the dialog (animation works)
- LinkA is removed from the document
- User clicks LinkB, showMyDialog is called with LinkB as the single parameter (animation works)
- User closes the dialog; error occurs because BasicDialog.hide() is still trying to reference LinkA as the animateTarget

To debug this I did two things:
- Use an event listener on BasicDialog.beforehide to dump my dialog with FireBug before it is hidden - animateTarget is LinkB as I would expect
- Dump this.animateTarget into FireBug's console from BasicDialog.hide - animateTarget is still LinkA!

Does anyone have any tips here? Any similar problems? I can't figure out why the looking at the dialog externally, I would see the correct animateTarget, but looking at "this" internally, I see something different.

Thanks a bunch

27 Feb 2007, 9:56 AM

27 Feb 2007, 10:05 AM
thanks Jack, I tried that, but then it doesn't seem to animate the hide() (on the first invocation or future ones)

by the way I am getting my company to donate in the next day or so - THANK YOU for all of your efforts!

28 Feb 2007, 9:47 AM
That's the syntax I always use and it animates on the hide back to the original element. Do you have any other details?

28 Feb 2007, 12:30 PM
thanks for your help jack. since this isn't a mission critical problem I'm not going to take your time (or mine) to debug it right now. I probably will take a closer look at it soon though, so I'll post any interesting results here. thanks again.

1 Mar 2007, 2:29 PM
huh, just a quick note on this, it does animate back if the dialog is cleared via dialog.hide(), but when I click the "close" icon, it doesn't animate. Looking at the code I can't understand why, I promise to try to debug this more deeply at some point soon.