【问题标题】:simplemodal, close and then immediately reopensimplemodal,关闭然后立即重新打开
【发布时间】:2009-11-11 20:09:08
【问题描述】:

我很想使用 simplemodal jquery 插件来显示一些 HTML。我在这个 html 中有一个 ajax 按钮,按下该按钮会将一些更宽的 HTML 内容返回到模式框。

似乎没有办法让simplemodal“意识到”这一点并让它自动调整大小,所以我想做的就是在按下ajax按钮时杀死模态,然后在之后重新创建它内容已返回并让初始自动调整大小处理它。但是我不知道如何使这项工作。

到目前为止我有:

$('#Element input.Ajax').click(function (e) {

//Get Ajax content and return to div 

$.modal.close();

$('#Element').modal(
              {
              onOpen: function (dialog) 
              {
              dialog.overlay.fadeIn('slow', function () 
                  {dialog.data.hide();
                   dialog.container.fadeIn('slow', function ()  
                      {dialog.data.slideDown('slow');});
                  });
               },
            onClose: function (dialog) 
                {
                dialog.data.fadeOut('slow', function () 
                    {
                    dialog.container.hide('slow', function () 
                        {
                        dialog.overlay.fadeOut('slow', function () 
                            {$.modal.close();});
                        });
                    });
                },
            overlayClose:true,
            opacity: 75,
              });

但是这些代码所做的只是关闭覆盖而不重新打开。

【问题讨论】:

    标签: jquery simplemodal


    【解决方案1】:

    您还可以确定新数据的尺寸并相应地调整容器的大小。

    但是,根据您的方法,您可以执行以下操作:

    // inside the onShow callback for the first modal, bind the click event
    onShow: function (dialog) {
        $('#Element input.Ajax', dialog.container[0]).click(function (e) {
            $("#new-modal").load("page.html", function () {
                $("#new-modal").modal({
                    // your options
                });
            });
        });
    }
    

    希望对您有所帮助。

    -埃里克

    【讨论】:

      猜你喜欢
      • 2017-11-21
      • 2016-03-19
      • 1970-01-01
      • 1970-01-01
      • 2018-11-05
      • 1970-01-01
      • 2017-08-20
      • 2014-11-23
      • 2018-05-02
      相关资源
      最近更新 更多