2014-01-06 115 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

讓我看看你的提交代碼。 –