dialog and dynamic forms

dialog and dynamic forms

Hi all, im trying to use dialog/ui in an environment where I am  creating forms on the fly. Basically on clicking of a button im using ajax to grab a form,  placing the form in a div, then call dialog on that div.

This goes fine the first time, but a second attempt at doing the same fails miserably. The content of the previous form is still being used, and things go all haywire.

Ive tried destroying the dialog before starting a new dialog, but that doesnt seem to help. I can see in the dom that the old form still exists. 

Is there something I need to do so the old dialog is completely gone and im back to the beginning, so I can re-start a new dialog on a newly grabbed form?

Any help appreciated,

Cor