1

我很想使用 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,
              });

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

4

1 回答 1

0

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

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

// 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
            });
        });
    });
}

希望有帮助。

-埃里克

于 2009-11-16T04:21:55.910 回答