2014-01-06 75 views
1

我有一个Fancybox窗体(iframe)。当用户提交表单时,我会刷新父页面。但是,如果用户决定关闭Fancybox表单而不提交,则父页面的刷新仍在进行。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> 

有没有一种办法后,才提交刷新父页面,如果用户点击在Fancybox的“x”或外部,它只是关闭花式框而不刷新?

谢谢。

回答

0

卸下重装行:

afterClose : function() { 
       parent.location.reload(true); 
     } 

parent.location.reload将再次加载页面。

添加重装代码成功函数这样

function showResponse_editprod(responseText, statusText, xhr, $form){  
    parent.location.reload(true); 
} 
+0

删除线也将从表格后重装停止父页面提交。 – DanielOlivasJr

+0

你可以在'submit'函数中写入这个代码而不是'onclose'。 –

+0

让我看看你的提交代码。 –