【发布时间】:2014-01-06 04:34:01
【问题描述】:
我有一个 Fancybox 表单 (iframe)。当用户提交表单时,我让它刷新父页面。但是如果用户决定关闭Fancybox表单而不提交,父页面的刷新仍然在发生。
这是我喜欢的盒子代码:
<script language="JavaScript">
$(document).ready(function() {
$(".edit_product").fancybox({
autoScale : true,
fitToView : false,
autoSize : false,
closeClick : false,
openEffect : 'none',
closeEffect : 'none',
title : '',
type : 'iframe',
afterClose : function () {
parent.location.reload(true);
}
});
});
</script>
这是提交代码:
<script type="text/javascript"> //EDIT PRODUCT
$(document).ready(function() {
var options = {
target: '',
dataType: 'html',
beforeSubmit: showRequest_editprod,
success: showResponse_editprod
};
$(".edit_product_div").delegate("#edit_product_form","submit",function () {
$("#edit_product_loading").show(500);
$(this).ajaxSubmit(options);
return false;
});
});
function showRequest_editprod(formData, jqForm, options){
return true;
}
function showResponse_editprod(responseText, statusText, xhr, $form){
parent.jQuery.fancybox.close();
}
</script>
有没有办法在提交后只刷新父页面,如果用户点击“x”或Fancybox之外,它只是关闭fancy box而不刷新?
谢谢。
【问题讨论】: