search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Closed modal not cleaning up after itself?

Asked by Matt
3 years ago.


It looks like when the modal is closed, it doesn't dispose of the extra HTML\iFrame it produces. On repetitive opening and closing of modals this can build up quite substantially on a single page.

First Modal Popup

Second Modal Popup

I've tried closing the model from within the modal itself and from the parent page but both leave this html in the parent to build up. This is also the case for the example on DayPilot website (where I got the screenshots). This also occurs if you reopen the same event over and over.

Development issue - If you've enabled "Browser Link" in visual studio while debugging, this can eventually stop your modal from loading altogether, this doesn't appear to happen on the DayPilot site, but maybe something to be aware of during dev.

Is there a built in function within the DayPilot libraries to avoid this? Is this even a known issue?

Answer posted by Dan Letecky [DayPilot]
3 years ago.

This is how it works at the moment:

If the modal displays a URL (and not custom HTML) it creates an iframe object and uses it to display the target page. Creating the iframe is expensive so it keeps that object for reuse even if you close the modal. Next time you open an URL using the same DayPilot.Modal object it should use that iframe - it should also be a bit faster.

Now, the problem with the demo is that it always creates a new DayPilot.Modal object (which is not in line with the iframe caching).

The reference to the cached object is available as DayPilot.Modal.div so you can remove the object manually:

modal.div = null;

The next version of DayPilot.Modal will introduce .disposeOnClose property (it will be set to true by default). It will remove the div (and iframe) on close if set to true.

Comment posted by B
3 years ago.

Hi Dan

Is .disposeOnClose property available now? or is there any other mechanism so that we can cache the iFrame?


This question is more than 3 months old and has been closed. Please create a new question if you have anything to add.