开发者

jQuery UI: Auto center on resize

Can anyone show me how to set it to auto center on browser resize? I know there are many answered questions regarding this matter, but I'm a total amateur. I need someone to rewrite the following code for me, please.

Thanks.

<script type="text/javascript">

    function openDialog(url) {
        $("<div class='popupDialog'>Loading...</div>")
            .dialog({
                autoOpen: true,
                closeOnEscape: true,
                width: '900',
                height: '800',
                modal: true,
                title: 'Bonus Features'
            }).bind('dialogclose', function() {
                jdialog.dialog('destroy');
            }).load(url, function() {
                $(this).dialog("option", "position", ['center', 'center'] );
            });
    }
</sc开发者_如何学Pythonript>


I'm not very familiar with jdialog or whatever plugin you're using, however, you can bind onto the window resize event.

$(window).bind('resize.dialog', function(e) {
  /* resize dialog */
});

If there's no method to resize the "jdialog" you could just close and reopen the dialog every time, but that seems undesirable.


you can add a window resize event to reset the position to center, center

example: http://jsfiddle.net/pxfunc/byknH/

$(window).resize(function() {
    $('.popupDialog').dialog({position: ['center', 'center']});
});


I added this as part of your other question, but here it is again...

<script type="text/javascript">

    function openDialog(url) {
        $("<div class='popupDialog'>Loading...</div>")
            .dialog({
                autoOpen: true,
                closeOnEscape: true,
                height: '1012',
                modal: true,
                position: ['center', 'center'],
                title: 'About Ricky',
                width: 690
            }).bind('dialogclose', function() {
                jdialog.dialog('destroy');
            }).load(url, function() {
                $(this).dialog("option", "position", ['center', 'center'] );
            });
    }

    // This part does the center on browser resize...
    $(window).resize(function() {
        $(".ui-dialog-content").dialog("option", "position", ['center', 'center']);
    });
</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜