Jquery – Problem with simplemodal jQuery

jquerysimplemodal

I use this call to create modal window using 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',
        });
    });

The html output is fairly simple. Among the data is empty div –

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

The problem is that, button in the same form does ajax call and fills #errors with errormessages and the simplemodal wrapper does not autoResize. Even calling

$.modal.resize();

does nothing.

Edit:
The call that fills #errors is this:

$("#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;
});

Using live there because the button too comes from previous ajax call.

Am i doing something wrong? Is there a way to get this working without my own function for resizing the window?

Alan

Best Answer

try the following error function in the ajax call:


error : function(){
                $("#errors").html("<p>Fail!</p>");
                $(".simplemodal-container").css("height", "auto");
        }