1

我使用此调用使用 simplemodal ( http://www.ericmmartin.com/projects/simplemodal/ ) 创建模式窗口:

$.get("openform/", function(data){
    $.modal(data, {
        closeHTML:'<a class="modalCloseImg simplemodal-close" title="Close"/>',
        minHeight:400,
        autoResize:'True',
        });
    });

html 输出相当简单。数据中有空的 div -

<div id="errors"></div>

问题是,相同表单中的按钮会调用ajax 并用错误消息填充#errors,而simplemodal 包装器不会自动调整大小。甚至打电话

$.modal.resize();

什么也没做。

编辑:填充#errors 的调用是这样的:

$("#addk").live("click", function(event){
    $.ajax({
        type: "POST",
        url: "savenow/",
        data: $("#form").serialize(), 
        success: function(msg){
            $("#errors").html(msg);
            $.modal.resize();
        },
        error : function(){
            $("#errors").html(<p>Fail!</p>);
        }
    });
    return false;
});

在那里使用 live 因为按钮也来自以前的 ajax 调用。

难道我做错了什么?有没有办法让这个工作没有我自己的调整窗口大小的功能?

艾伦

4

2 回答 2

1

first (and this is not the root of your troubles): 'True' and 'true' are strings, as are 'False' and 'false'. All these strings are "truish" in boolean contexts.

second: a quick peek in the source of simplemodal 1.3.3 reveals that autoResize kicks in only when the browser window is resized, which is not your case at all.

于 2009-12-20T16:32:24.300 回答
1

try the following error function in the ajax call:


error : function(){
                $("#errors").html("<p>Fail!</p>");
                $(".simplemodal-container").css("height", "auto");
        }
于 2009-12-20T17:14:15.560 回答