当我的表单被提交和验证时,我希望我的对话框淡出并关闭,我不希望页面自动刷新。如果我使用 preventdefault 页面不会刷新,但对话框也不会关闭。我还需要做什么?
$("#form").validate({
rules: {
number : {
required: true
}
},
messages: {
number : {
required: "enter a phone number"
}
},
submitHandler: function(form,event) {
event.preventDefault();
//this prevents a double click on the form button
$("form :input:submit").click(function() {
this.disabled = 'disabled';
});
//Here I want the dialog to slowly fade, then close, *then* reload the page.
//but it won't fade or close when I'm using preventDefault().
$('#dialog').fadeOut('slow', function(){
$( this ).dialog( "close" );
location.reload();
});
} //closes submit handler
});//close validate