Dialog architecture problem

Dialog architecture problem


Hi there,
I'm using the dialog component for a new project and I firstly used it
3 days ago. This was the best component I've found on the web and so I
grabbed it. Then began testing it and I was disappointed when I
realized that you could just open multiple dialogs with a single link
to it. I'm not sure if it's provided in the options; but I couldn't
find. I saw that after opening a dialog, if you click on the link that
triggers this incident, a new dialog is created and the last dialog's
content moves to this very new dialog. Then I looked at the DOM tree
using Firebug and voila! I saw that even if you close the dialog box
and re-open it, the same thing happens. The content is removed from
the last dialog to a new one and the old one just stays in the DOM
tree.
I thought it should create a dialog for just once (for a link) and
then populate the content once. In addition, using the same link to
the dialog, a new dialog shouldn't be created as there's already an
open one. If you close the dialog, it should hide and if you re-open
it, it should just show it's contents. To achieve this, I did this:
( I'm doing this for just one dialog. You should modify it if you'll
use multiple dialogs )
var openedBefore = false;
if ( !openedBefore ){
$("#dialog").dialog({...});
openedBefore = true;
} else {
$("#dialog").show();
}
I think this shouldn't be done in this way. Have I missed a piece
somewhere? What do you think/know about it?
Thanks,
Onur