问题
How can I stop the closing of an AJAX page displayed in a fancybox?
<a href="sample.php?name=name1&feedback=feedback1" id="feedback">feedback</a>
fancybox code in jquery...
$("#feedback").fancybox({
'speedIn' : 600,
'speedOut' : 200,
'centerOnScroll': false,
'autoDimensions': true
'type' : 'ajax',
});
sample.php page will be displayed in fancybox. once user click submit button in sample.php. fancybox closes. i need to make delay in closing after submitting feedback form(sample.php)
回答1:
You didn't posted code So I can only guess:
You can add this options:
showCloseButton: false // this will hide the close button
hideOnContentClick: false // this will not close fancybox when clicked inside
hideOnOverlayClick: false // this will not closefancyvox when clicked outside
You can also manually close fancybox by calling $.fancybox.close
You can check for more in the API docs
Hope its what you need.
UPDATE:
To be able to close manually fancybox after form submit you need to post the form by ajax and close fancybox on success or failure using '$.fancybox.close
'
You can bind the ajax to your form like this:
$('#yourForm').bind('submit', function() {
$.ajax({
url: 'yourpage.php',
success: function(data) {
if (data == 'Error') { alert('An error occurred')}
else { $.fancybox.close }
}
});
});
Check the jQuery docs to read more about the ajax() function and do some search in the official fancybox support group for more information.
来源:https://stackoverflow.com/questions/4388354/stop-the-closing-of-an-ajax-page-displayed-in-fancybox