我在 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
});