Recently I’ve been working on structuring and refactoring javascript code in a middle size application. There are many modal popups, you know popup invoking popup and so on. Many of them were just created on div elements which already exist in the html markup. I thought that it would be a better idea to create these kinds of div elements only if I want to show a dialog using them. The next thing I’d like to achieve is to use default configuration for created dialogs. Also, I want my div element destroyed after closing the dialog.

Ok. Enough talking. Show me the code.

And usage.