0

I'm trying to submit a form who is rendered in a SimpleModal dialog, but my submit is never called when I'm using FF3 & Opera (Chrome, Safari and IE works). I use the following code:

function ShowModal(rendercontainerid, modalcontainerid, url) {
    if (url == '')
        return;
    $.get(url, function(data) {
        $(rendercontainerid).html(data);
        $(rendercontainerid).modal({ 
            close: false,
            containerId: modalcontainerid,
            onOpen: function(dialog) {
                dialog.overlay.fadeIn('slow', function() {
                    dialog.container.slideDown('slow', function() {
                        dialog.data.fadeIn('slow');
                    });
                });
            },
            onClose: function(dialog) {
                dialog.data.fadeOut('slow', function() {
                    dialog.container.slideUp('slow', function() {
                        dialog.overlay.fadeOut('slow', function() {
                            $.modal.close(); // must call this!
                        });
                    });
                });
            }
        });
    });
}

function CloseDialog() {
    $.modal.close();
}

function SubmitAndClose(rendercontainerid) {
    $(rendercontainerid).find('form').submit();
    CloseDialog();
    window.location = window.location;
}

function AjaxSubmitAndClose(rendercontainerid) {
    var form = $(rendercontainerid).find('form');
    var url = $(form).attr('action');
    var postData = $(form).serializeArray();

    var options = {
        dataType: 'json',
        success: AjaxSubmitSucces
    };

    $(form).ajaxSubmit(options);
}

function AjaxSubmitSucces(data) {
    if (data.ErrorMessage != '') {
        alert(data.ErrorMessage);
    }
    else if (data.RedirectUrl != '') {
        CloseDialog();
        window.location = data.RedirectUrl;
    }
}

I also tried to the jquery.form plugin for ajax posting but then you will see the formdata(An fckeditor) is in the initial values(it looks like it is cached).

4

1 回答 1

1

尝试使用 onShow 回调:

onShow: function (dialog) {
  // bind form submit in dialog
  dialog.data.find('form').submit(function (e) {
    e.preventDefault();
    // do stuff here
  });
}
于 2008-12-28T17:15:47.993 回答