我在一个页面上有多个表单,对于每个表单,我希望用户在提交表单之前进行确认。但是当用户确认提交时,我如何让这个对话框知道用户正在提交哪种表单?它需要自定义参数吗?谢谢。
$("#dialog-confirm").dialog({
resizable: false,
height:140,
modal: true,
buttons: {
'Confirm submit': function() {
document.______???????_____.submit();
},
Cancel: function() {
$(this).dialog('close');
}
}
});
$('.allForms').submit(function(){
$('#dialog-confirm').dialog('open');
});
最佳答案
您可以将其存储在如下变量中:
var currentForm;
$("#dialog-confirm").dialog({
resizable: false,
height:140,
modal: true,
buttons: {
'Confirm submit': function() {
currentForm.submit();
},
Cancel: function() {
$(this).dialog('close');
}
}
});
$('.allForms').submit(function(){
currentForm = this;
$('#dialog-confirm').dialog('open');
return false;
});
由于您只是使用此功能并立即离开页面,因此没有真正的理由使其变得比这更复杂。
关于jquery - 使用 jquery ui 对话框确认表单提交操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2420773/