closing jquery modal dialog is slow
jquery, jquery-ui
Solution
Get rid of the close call from the close event on your dialog setup:
var $dialog = $('#cameraform').dialog({
modal:true,
autoOpen: false,
resizable:false,
width: 625,
close: function() {
// $(this).dialog('close'); //this is slow
}
}); //init dialog
You are calling the close event from within itself, thus resulting in a overflow of the call stack.
Problem
I have a modal dialog where I place the contents of an html form inside. The form has a submit and cancel button. I'm finding the cancel button or even closing the dialog by hitting the x quite slow. It is only a few seconds too slow but it is long enough to think there is a problem that crazy mouse clickers might go nuts. Is there a better way to use the close function and a better way to cancel the changes than what I'm doing: ``` var $dialog = $('#cameraform').dialog({ modal:true, autoOpen: false, resizable:false, width: 625, close: function() { $(this).dialog('close'); //this is slow } }); //init dialog //events $('.addwebcam').click(function(e) { $dialog.dialog('open'); }); $(".cancel_changes").click(function() { $dialog.dialog('close'); //this is slow }); ``` HTML: ``` <button class="addwebcam">Add Webcam</button> <div id="cameraform" title="Add a camera"> ...//my form <button type='button' class='cancel_changes' name='cancel_changes' value='Cancel'>Cancel</button> </div> ``` Any optimization I can do here? Thanks in advance.