0

我对这个线程有同样的问题:关于 SimpleModal jQuery 插件的问题 -- 初始打开后可能重新居中吗?

我尝试了可能的解决方案,但没有成功。我的页面有一个滚动条,打开模式后,我有一些调整 div 大小的操作。但是当 div 超出窗口可见区域时,超出的内容被隐藏。当我滚动页面时,模态保持在同一位置!

它在 IE6 上运行良好,在 IE8 上运行良好。

4

2 回答 2

0

我建议设置max-height 和 max-width以防止对话框变得太大。然后你可能需要确保这个 div 的样式包括overflow:scroll

于 2010-06-30T16:20:04.463 回答
0

可能的解决方案示例:

$('#modalContent').modal({
    onShow: function (dialog) {
        var sm = this;

        // bind click event to get ajax content
        $('.link', dialog.container[0]).click(function (e) {
            e.preventDefault();

            $.ajax({
                ..., // your settings here
                success: function (data) {
                    dialog.data.html(data); // put the data in the modal
                    dialog.container.css({height:'auto', width:'auto'}); // reset the dimensions
                    sm.setContainerDimensions(); // resize and center modal

                    // if you want to focus on the content:
                    sm.focus();

                    // if you want to rebind the events
                    sm.unbindEvents();
                    sm.bindEvents();
                }
            });
        });
    }
});

我将考虑在 SimpleModal 中放置一个调整大小的函数,它会处理这些步骤中的大部分。在那之前,这应该对你有用。

-埃里克

于 2010-06-30T18:45:16.170 回答