[英]Fancybox, only refresh parent page after submit, but not on close
我有一个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而不刷新?
谢谢。
删除重装线:
afterClose : function () {
parent.location.reload(true);
}
parent.location.reload
将再次加载页面。
将重新加载代码添加到成功函数中,如下所示
function showResponse_editprod(responseText, statusText, xhr, $form){
parent.location.reload(true);
}
$(".fancybox").fancybox({
afterClose : function() {
location.reload();
return;
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.