Javascript on Dialog run twice?

Javascript on Dialog run twice?

I have a JQuery UI Dialog and there is some Javascript on the content of this dialog.

I noticed that my debugging calls were being hit twice, so I looked into the call stack of each and found that one of the calls was from the creation of the dialog (with autoOpen: false) and the second was from the opening of the dialog.

Is there a good way to prevent this from happening? Some of the code is going to our web server and then to our application server, so two calls is a waste.

I've written some code that will prevent the Javascript from running when the dialog is only "created", but it requires that the content know that it is inside of a dialog, which I would prefer not happen if possible, for future re-use (the content is in an ASP.NET user control).

Thanks,
Craig