SimpleModal 调整容器大小

发布于 2024-07-11 02:35:59 字数 2282 浏览 7 评论 0原文

我使用过 SimpleModal。 现在的问题是模式对话框的大小调整。 我有一个确认对话框,按“是”后它基本上很小。

第二个是my.php,它包含大量数据。 我正在使用的概念 附加一个已经存在的模型。 如何调整内容大小?

我的 JavaScript 片段有:

$(document).ready(function () {
    $('#confirmbutton, #confirmDialog a.confirm').click(function (e) {
        e.preventDefault();

        confirm("Continue to the SimpleModal project page?", function () {
        window.location.href = 'http://localdata/';
        });
    });
});

function confirm(message, callback) {
    $('#confirm').modal({
        close:false,
        position: ["20%",],
        overlayId:'confirmModalOverlay',
        containerId:'confirmModalContainer',
        onShow: function (dialog) {
            dialog.data.find('.message').append(message);

            // If the user clicks "yes"
            dialog.data.find('.yes').click(function () {
                // Call the callback
                // $.modal.close();

                $.get("my.php", function (data) {
                    /* Sample response:
                     *   <div id="title">My title</div>
                     *   <div id="message">My message</div>
                     *
                    */

                    var resp = $("<div/>").append(data);
                    var title = resp.find("#title").html(),
                    message = resp.find("#message").html();
                    dialog.data.find(".header span").html(title);
                    dialog.data.find(".message").html(message);
                    dialog.data.find(".buttons .yes").hide();
                    dialog.data.find(".buttons .no").hide();

                    //dialog.data.find(".buttons .no").html("Close");

                    // No need to call the callback or $.modal.close()
                });// End for click
            });//End for on show
        } //End for modal
    }); //Close for modal
}

我的 CSS:

confirmModalContainer {height:700px; width:700px; font-family:'Trebuchet MS', Verdana, Arial; font-size:16px; text-align:left; background:#fff; border:2px solid #336699;}

如何修改 SimpleModal 容器大小? 在 Ajax 通话中?

I have used SimpleModal. Now the problem is the resizing of the modal dialog.
I have a confirm dialog, and it is basically small after pressing Yes.

The second one is my.php and it contains large data. I am using the concept of
appending an already existing model. How do I resize the content?

And my JavaScript snippet has:

$(document).ready(function () {
    $('#confirmbutton, #confirmDialog a.confirm').click(function (e) {
        e.preventDefault();

        confirm("Continue to the SimpleModal project page?", function () {
        window.location.href = 'http://localdata/';
        });
    });
});

function confirm(message, callback) {
    $('#confirm').modal({
        close:false,
        position: ["20%",],
        overlayId:'confirmModalOverlay',
        containerId:'confirmModalContainer',
        onShow: function (dialog) {
            dialog.data.find('.message').append(message);

            // If the user clicks "yes"
            dialog.data.find('.yes').click(function () {
                // Call the callback
                // $.modal.close();

                $.get("my.php", function (data) {
                    /* Sample response:
                     *   <div id="title">My title</div>
                     *   <div id="message">My message</div>
                     *
                    */

                    var resp = $("<div/>").append(data);
                    var title = resp.find("#title").html(),
                    message = resp.find("#message").html();
                    dialog.data.find(".header span").html(title);
                    dialog.data.find(".message").html(message);
                    dialog.data.find(".buttons .yes").hide();
                    dialog.data.find(".buttons .no").hide();

                    //dialog.data.find(".buttons .no").html("Close");

                    // No need to call the callback or $.modal.close()
                });// End for click
            });//End for on show
        } //End for modal
    }); //Close for modal
}

My CSS:

confirmModalContainer {height:700px; width:700px; font-family:'Trebuchet MS', Verdana, Arial; font-size:16px; text-align:left; background:#fff; border:2px solid #336699;}

How do I modify the SimpleModal container size? On an Ajax call?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

安稳善良 2024-07-18 02:35:59

只要这样做....

$("#simplemodal-container").css('height', 'auto'); //To reset the container.
$(window).trigger('resize.simplemodal');           //To refresh the modal dialog.

Just do this....

$("#simplemodal-container").css('height', 'auto'); //To reset the container.
$(window).trigger('resize.simplemodal');           //To refresh the modal dialog.
謌踐踏愛綪 2024-07-18 02:35:59

我想建议一个更简单、更灵活的解决方案:

访问 http://www.ericmmartin.com /simplemodal-test/,在Firebug中运行以下代码,然后单击对话框中的“按钮”来调整其大小。

// Inject a CSS class into the document
$('head style[type=text/css]').append('.wide{width:750px !important;}');

$('#modalContentTest').modal({
  onShow:function(dialog){
    dialog.data.find('.animate').click(function(){

      // You can put this code in your "my.php" callback

      dialog.container.addClass('wide');

      /*
      // OR set the width explicitly
      // (make sure you remove the addClass line if you want to use this)
      dialog.container.width(700);
      */

      /*
        Force SimpleModal to reposition the 
        dialog by triggering its resize event
      */
      $(window).trigger('resize.simplemodal');

    }); //end click
  } // end onShow
}); // end modal

使用此方法,您不必定义新的 CSS 来重新居中对话框,并且可以让 SimpleModal 处理浏览器不一致的问题。

I'd like to suggest a simpler and more flexible solution:

Visit http://www.ericmmartin.com/simplemodal-test/, run the following code in Firebug and then click on "button" in the dialog to resize it.

// Inject a CSS class into the document
$('head style[type=text/css]').append('.wide{width:750px !important;}');

$('#modalContentTest').modal({
  onShow:function(dialog){
    dialog.data.find('.animate').click(function(){

      // You can put this code in your "my.php" callback

      dialog.container.addClass('wide');

      /*
      // OR set the width explicitly
      // (make sure you remove the addClass line if you want to use this)
      dialog.container.width(700);
      */

      /*
        Force SimpleModal to reposition the 
        dialog by triggering its resize event
      */
      $(window).trigger('resize.simplemodal');

    }); //end click
  } // end onShow
}); // end modal

With this method you don't have to define new CSS to re-center the dialog and you can let SimpleModal take care of browser inconsistencies.

屋檐 2024-07-18 02:35:59

您可以通过添加和删除 modalContainer 元素的类来完成此操作。

Fog Creek Copilot 使用 SimpleModal,有两种尺寸,正常和宽。 如果您进入 Copilot 并单击“登录”,您将看到正常大小。 现在,放入 Firebug 的控制台,

>> $('.modalContainer').addClass('wide')

您应该会看到容器变得更宽。 要在您的网站上实现此功能,您所要做的就是为您想要的所有尺寸定义类,并动态添加和删除它们。

You can do it by adding and removing classes for the modalContainer element.

Fog Creek Copilot uses SimpleModal, with two sizes, normal and wide. If you go Copilot and click 'Log In', you'll see the normal size. Now, put into Firebug's console

>> $('.modalContainer').addClass('wide')

You should see the container get wider. All you have to do to make this work on your site is define classes for all the sizes you want, and add and remove them dynamically.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文