我们有这个jquery函数,单击该按钮即可提交表单。请记住,该按钮的类型为Submit。
$("#btn-modal-confirm-Restart").click(function () {
var included = 0;
$('.icheck').each(function () {
var index = $(this).data('row-index');
var isIncludedCheckBox = $('#Items_' + index + '__IsIncluded');
if (isIncludedCheckBox.is(':checked')) {
included++;
}
});
if (included === 0) {
$('#confirmation-modal').modal('hide');
$("#message-content").html(
"<div class='alert alert-error'>" +
"<button class='close' data-dismiss='alert' type = 'button' >×</button >" +
"<span>" +
"You must include at least one item before clicking on Finish." +
"</span>" +
"</div >");
return false;
}
$('#confirmation-modal').modal('hide');
$('#modal-waiting').modal({
keyboard: false,
backdrop: 'static'});
});
我们不会进入if和if的条件,因此它将在提交表单时进行。 该函数需要花很多时间才能隐藏在模式中,因为它进入了jquery,并且通过诊断分析,呈现延迟的jquery摘录如下:
if (!(eventHandle = elemData.handle)) {
eventHandle = elemData.handle = function (e) {
// Discard the second event of a jQuery.event.trigger() and
// when an event is called after a page has unloaded
return typeof jQuery !== core_strundefined && (!e || jQuery.event.triggered !== e.type) ?
jQuery.event.dispatch.apply(eventHandle.elem, arguments) :
undefined;
};
// Add elem as a property of the handle fn to prevent a memory leak with IE non-native events
eventHandle.elem = elem;
}
遵循浏览器性能报告的证据:enter image description here
解决方案:我们通过本机js提交提交表单