如何在动态创建的表单中捕获提交响应?

时间:2013-09-25 16:45:56

标签: javascript jquery asp.net-mvc forms jquery-jtable

我在jTable-create / edit弹出窗口中创建了一个form-iframe组合,以允许上传文件:

$('#someContainer').jtable({
    ...
    FileUploadDownload: {
        input: function (data) {
            if (typeof data.record  == 'undefined' || !data.record.IsFileLoaded) {
                return '<form target="iframeTarget" class="formUploadFile" action="PostFile" method="post" enctype="multipart/form-data"> <input type="file" onchange="hideButtons(); this.form.submit()" name="myFile"/> </form> <iframe class="upload-iframe" style="display: none;" src="#" name="iframeTarget"></iframe>';
            }
            else {
                return '<a href="DownloadFile?id=' + data.record.Codigo + '">Download</a> <a onclick="ReWriteInputControl(' + data.record.Codigo + ', $(this))">Remove File</a>'
            }
        }
    }
}

我的服务器代码:

[HttpPost]
public JsonResult PostFile(HttpPostedFileBase myFile)
{
    if (myFile != null && myFile.ContentLength > 0)
    {
    ...
    }
    return Json(true);
}

一切正常。

现在我想捕获响应以重新启用弹出窗口的某些控件。 #jtable-edit-form is the id of a parent div of the popup created by jTable .formUploadFile is a class of the form.

我试图这样做,但不起作用:

$("#jtable-edit-form").on("submit", ".formUploadFile", null, function (event) {
    alert("Catch the submit");
    //re-enable some inputs, etc
});

0 个答案:

没有答案