PDA

View Full Version : YAHOO.widget.calendar destroy



kolyan
12 Jan 2007, 12:58 AM
Hi all!

Can anyone tell me how to solve such problem:
When I open BasicDialog, body is updating using ajax. There is some <div id="cal1"></div> in updated body. So, I create YAHOO calendar in "cal1", and it works well. But, when I open Dialog again (with updating dialog body), old calendar doesn't work (it's not strange because id is the same (cal1), but element object of this div is another), and I have to create one more calendar object. Everything would be ok, but when I create each calendar - browser take a couple megabytes of RAM, that is not good.
So the question is: how to avoid using extra memory (to destroy calendar, or to reuse old calendar).

Hope for your help.

Animal
12 Jan 2007, 1:27 AM
The simple answer is only have one calendar. Don't create and destroy it every time in the Dialog, have a singleton MyCalendar object which encapsulates a Calendar which can be shown anywhere. Use that within the Dialog.

kolyan
12 Jan 2007, 1:38 AM
The simple answer is only have one calendar. Don't create and destroy it every time in the Dialog, have a singleton MyCalendar object which encapsulates a Calendar which can be shown anywhere. Use that within the Dialog.

I agree with you. But how to use YAHOO.widget.calendar in this way? How to change container element for calendar?

Animal
12 Jan 2007, 2:02 AM
Don't change the container. Just create one container with one Calendar in it, and use that wherever you need a Calendar. This is what we do - there's just one Calendar in a YAHOO.widget.Overlay. That's popped up wherever needed.

kolyan
12 Jan 2007, 6:51 AM
It works! :)
Thanks for help.