Stop the closing of an AJAX page displayed in fancybox?

两盒软妹~` 提交于 2019-12-11 05:45:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!