Add buttons within plugin, return value

Add buttons within plugin, return value

Hi
 
I created a plugin where I use overlay to display yes/no dialog, using the jquery tools overlay tutorial as a guide:

http://flowplayer.org/tools/demos/overlay/modal-dialog.html

 
It displays ok first time, after that click on the button will not close the dialog.

I add buttons using append() method and remove them using either empty() or remove() method. The problem occurs when the buttons are removed and added again to a <div> container.

 
The other problem is how to return the users choice, ie which button they clicked - yes or no. I can bind click event of the button to a handler within plugin but I don't see the way to assign the value in an appropriate manner. - something like var result = $(selector).confirm(); .
 
I looked into onclose event but I haven't seen anything obvious to help me.
 
I am not posting entire plugin code here to keep the post short, but I will do it if required.
 
Any help with these problems will be greatly appreciated.