JQuery UI Dialog slow

后端 未结 8 1520
夕颜
夕颜 2021-01-17 22:48

I\'ve recently ran into a bit of a pain. I\'ve been using the JQuery Dialog box to display some configuration screens in a web app. Nothing too special. However I have a cou

8条回答
  •  伪装坚强ぢ
    2021-01-17 23:01

    I just ran into this issue using a tabbed dialog with hundreds of checkboxes. I found this link to be very helpful. Took 17s to open the dialog before, but now it's down to about 1.3s. (I'm using a draggable non resizeable dialog)

    The trick is to detach the html before you open the dialog, and then use the open function for the dialog to reattach the content.

    $('#triggerDialogFast').click(function () {
        var $dialogContainer = $('#dialogContentFast');
        var $detachedChildren = $dialogContainer.children().detach();
        $dialogContainer.dialog({
            width: 425,
            height: 400,
            draggable: false,
            resizable: false,
            open: function () {
                $detachedChildren.appendTo($dialogContainer);
            },
        });
    });
    

    I'm not sure but it should probably work by just attaching the html in the open function if that is possible in your scenario.

提交回复
热议问题