tbarstow
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;
this.dialog.show();
}
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
Taylor
this.showMyDialog = function(animateTarget) {
if (!this.dialog) {
this.dialog = new YAHOO.ext.BasicDialog('myEl',{...});
}
this.dialog.animateTarget = animateTarget;
this.dialog.show();
}
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
Taylor