Events in dialogs

I’m opening a dialog via the Javascript AJS This is code from my velocity template.
Link below

The problem is that this code works only for the first show dialog. If I open a dialog, then close it and open up a second dialog this doesnt work

example in created gif

Whats problem?

Thanks for respond