Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery-UI Dialog Memory Leaks
    primarykey
    data
    text
    <p>I'm working with IE7 and some jQuery dialogs and I'm running into about a 6meg leak per dialog opened. I'm assuming it's to do with closures, but so far everything I've done to remove them haven't helped. At this point I think I've taken care of all the closures except on for a callback function I pass in, but it's still leaking 6 megs even after the dialog is closed and removed. The relevant source code is:</p> <pre><code>function DialogDestroyAndRemove(event) { $(event.target).dialog("destroy").remove(); } function CallbackAndCloseDialog(event) { if (event.data.callback != undefined) { event.data.callback(event.data.callbackResponse); } $("#" + event.data.dialogId).unbind('dialogbeforeclose').dialog('close'); } // alert dialog modal with ok button function AlertDialog(dialogTitle, dialogText, callbackFunction) { // dynamically generate and add a div so we can create the pop-up $('body').append("&lt;div id=\"alertDialog\" style=\"display:none;\" title=\"" + dialogTitle + "\"&gt;" + dialogText + "&lt;/div&gt;"); // define/configure the modal pop-up $("#alertDialog").dialog({ draggable: false, resizable: false, modal: true, autoOpen: true, open: function() { $("#alertDialog").parents('.ui-dialog-buttonpane button:eq(0)') .focus() //focus so the button is highlighted by default .bind('click', { callback: callbackFunction, callbackResponse: 'OK', dialogId: 'alertDialog' }, CallbackAndCloseDialog); }, overlay: { backgroundColor: '#000', opacity: 0.5 }, buttons: { 'OK': function() { } } }).bind('dialogbeforeclose', function(event, ui) { // Close (X) button was clicked; NOT the OK button if (callbackFunction != undefined) { callbackFunction('cancel'); } callbackFunction = null; }).bind('dialogclose', DialogDestroyAndRemove); } </code></pre> <p>One thing I did above that I'm not sure if it's needed was instead of defining the callback for the OK button when it's defined (and therefore having a closure since it's referencing the callback) to define it using a .bind once the dialog is open. I was hoping that being able to pass the callback as part of the data to the click event might help remove the closure.</p> <p>Any ideas what else I can change to get rid of this leak?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload