Recently, I’ve been working on structuring and refactoring javascript code in a middle-sized application. The application was extensively using modal popups, and the design allowed to stack popups on each other. Many of them were just created on div elements that already existed in the HTML markup. What I thought would be a better idea was to create div elements dynamically only if I wanted to show a dialog. The next thing I’d like to achieve was using a default configuration for created dialogs. What’s more, I wanted my div element destroyed after closing the dialog.

Alright. Enough talking. Show me some code!

And usage.