我希望用户在提交前确认。我有一个问题,因为当我点击“是”'什么都没发生,或者它做同样的事情,比如“没有”。按钮。我的部分代码是:
<div>
<form method="POST" action="add.php" name="alertowy" id="alertowy">
<button class='btn btn-primary' type='submit'>Send</button>
</form>
<div id="dialog-confirm"></div>
</div>
<script>
$('button[type=submit]').on('click', function(event) {
var submit = false;
$("#dialog-confirm").dialog({
resizable: false,
height: 190,
autoOpen: false,
width: 330,
modal: true,
buttons: {
"Yes": function() {
$(this).dialog("close");
submit = true;
},
No: function() {
$(this).dialog("close");
}
}
});
$('form').submit(function() {
if (!submit) {
$("#dialog-confirm").dialog('open');
return false;
}
});
});
</script>
也许我没有包含某些内容?我添加了这些文件:
<link rel="stylesheet" href="./css/kalendarz/jquery-ui.css">
<script src="./css/kalendarz/jquery-1.10.2.js"></script>
<script src="./css/kalendarz/jquery-ui.js"></script>