Open Fancybox (or equiv) from Form input type=“submit”

后端 未结 9 1403
无人及你
无人及你 2020-12-01 07:10

is there a way to get a fancybox (http://fancy.klade.lv/) or any other lightbox from submitting a FORM (with an image button)?

HTML looks like this:

         


        
9条回答
  •  無奈伤痛
    2020-12-01 07:26

    I believe all the other answers miss the point of the question (unless I am the one misunderstanding). What I think the author wanted was to have it such that when a form is submitted, its results are displayed in a fancybox. I didn't find that any of the other answers provided that functionality.

    To achieve this, I used the jQuery Form Plugin (http://malsup.com/jquery/form/) to easily convert the form to an ajax call. Then I used the success callback to load the response into a fancybox using a manual call to $.fancybox().

    $(document).ready(function() {
        $("#myForm").ajaxForm({
            success: function(responseText){
                $.fancybox({
                    'content' : responseText
                });
            }
        }); 
    });
    

    So instead of attaching fancybox to some artificial tag, you attach ajaxForm to the form itself.

提交回复
热议问题