我在页面上有多个表单(自动生成)。我要求用户确认删除记录。如果用户单击否,则关闭模态对话框并且没有任何反应,但是如果他单击是按钮,则不会再发生任何事情。有人可以帮忙吗?
以下是代码:
<input type="submit" value="Click me" class="button" />
<div id="modal">
<div id="heading">
Record will be deleted! Please Confirm.
</div>
<div id="content">
<p>Record will be deleted! This operation can't be undone. <br />Are you sure?</p>
<input type="button" onclick="return true;" class="button green close" value="Yes"></button>
<input type="button" onclick="return false;" class="button red close" value="No"></button>
</div>
$('.oneUser').on('submit',function(e){
$('#modal').reveal({
animation: 'fade',
animationspeed: 600,
closeonbackgroundclick: true,
dismissmodalclass: 'close'
});
return false;
});
答案 0 :(得分:1)
已更新,现在有A fiddle!
更新了标记
<form>
<input type="submit" value="Click me" class="button" id="submitButton" />
</form>
更新了脚本
var confirmDelete = $('<div></div>')
.html('Record will be deleted! This operation can\'t be undone. <br />Are you sure?')
.dialog({
autoOpen: false,
title: 'Record will be deleted! Please Confirm.',
buttons: {"Yes": function() {
$(this).dialog("close");
$('form').submit();
}, "No": function() {
$(this).dialog("close");
}
}
});
$('#submitButton').on('click', function(e){
e.preventDefault();
$(confirmDelete).dialog('open');
});
$('form').submit();
。