我的数据在我的jQuery对话框上发布了两次
在下面的对话框窗体中,我有两个按钮:保存和取消。当用户双击“保存”按钮时,我的数据将被发布2次。我怎样才能避免呢我的数据在我的jQuery对话框上发布了两次,jquery,jquery-ui,Jquery,Jquery Ui,在下面的对话框窗体中,我有两个按钮:保存和取消。当用户双击“保存”按钮时,我的数据将被发布2次。我怎样才能避免呢 $(this).dialog({ modal: true, resizable: false, title: "Edit", close: function () { $(this).dialog('destroy').remove(); }, buttons: {
$(this).dialog({
modal: true,
resizable: false,
title: "Edit",
close: function () { $(this).dialog('destroy').remove(); },
buttons: {
"Save": function () {
// Manually submit the form
var form = $('form', this);
$(form).submit();
},
"Cancel": function () { $(this).dialog('destroy').remove(); }
}
});
谢谢。这是个老问题。你可以做的一件事是
var submitted = false;
$(this).dialog({
modal: true,
resizable: false,
title: "Edit",
close: function () { $(this).dialog('destroy').remove(); },
buttons: {
"Save": function () {
// Manually submit the form
if(!submitted){
submitted = true;
var form = $('form', this);
$(form).submit();
}
},
"Cancel": function () { $(this).dialog('destroy').remove(); }
}
});