Reputation: 2634
I know there are multiple posts on this but I still can't get it right. I've tried so many combinations. I'm trying to create a dialog box when you click a button. Inside the dialog box is a form but that is not important for now. I can get the dialog to show up once but not on the second click. Here is what I have right now:
var $dialog = $('#cameraform').dialog({
modal:true,
autoOpen: false,
resizable:false,
width: 625,
close: function() {
$(this).remove();
}
}); //init dialog
//events
$('.addwebcam').click(function(e) {
$dialog.dialog('open');
});
HTML:
<button class="addwebcam">Add Webcam</button>
<div id="cameraform" title="Add a camera">
...//my form
</div>
I've also tried initializing the dialog in the click event but that doesn't work at all. What am I doing wrong.
Upvotes: 0
Views: 1207
Reputation: 1392
Isn't this line of code
$(this).remove();
removing your dialog box from the DOM?
I'd think to close the dialog, you'd use:
$( this ).dialog( "close" );
Upvotes: 4