# Dynamic Updating CreateDialog Problem

In this code, one cannot close the dialog window:

{TogglerBar[Dynamic[x], Range[5]], Dynamic[x],  Dynamic[CreateDialog[x]]}


If I use DynamicModule this way, the dialog window will not pop up when it was closed and re-chosen some values.

{TogglerBar[Dynamic[y],Range[5]],Dynamic[y],DynamicModule[{y=y},CreateDialog[y]]}


So how to make the created dialog window could be closed and reopen when click to set different values by TogglerBar

-
In the first example you give, you can close the dialog. It just so happens a new one is created whenever you close an old one. You can notice this through the names changing in the output. In the second case, you forgot your Dynamic around CreateDialog if that was what you are asking about. Perhaps you are simply looking for CreateDialog[Dynamic@y] ? –  jVincent May 16 '13 at 9:31
@jVincent Yeah, The first case just generate too many NotebookNojects. The second case: what I'm really looking for is How to Reopen the Dialog via Clicking in the TogglerBar. CreateDialog[Dynamic[y]] or Dynamic[CreateDialog[y]] seems doesn't work well. –  HyperGroups May 16 '13 at 9:42
I'm not sure if this fully answers your question, but here is a method of using the Dynamic to check if a dialog is already open and reopen it if it has been closed:
DynamicModule[{nb = CreateDialog[Dynamic@y]},