Link to home
Start Free TrialLog in
Avatar of NewtonianB
NewtonianB

asked on

jqery boxy automatically close box on submit

I'm using the following script from
http://www.varnagiris.net/2009/04/11/ajax-feedback-form-using-jquery-boxy-plugin/

How can I make it close the window automatically after it receives the callback inside function(data){?



$(function() {
    /* set global variable for boxy window */
    var contactBoxy = null;
    /* what to do when click on contact us link */
    $('.contact_us').click(function(){
        var boxy_content;
        boxy_content += "<div style=\"width:300px; height:300px\"><form id=\"feedback\">";
        boxy_content += "<p>Subject<br /><input type=\"text\" name=\"subject\" id=\"subject\" size=\"41\" /></p><p>Your name and/or email:<br /><input type=\"text\" name=\"your_email\" size=\"41\" /></p><p>Comment:<br /><textarea name=\"comment\" id=\"comment\" cols=\"39\" rows=\"5\"></textarea></p><br /><input type=\"submit\" name=\"submit\" value=\"Send >>\" />";
        boxy_content += "</form></div>";
        contactBoxy = new Boxy(boxy_content, {
            title: "Send feedback",
            draggable: false,
            modal: true,
            behaviours: function(c) {
                c.find('#feedback').submit(function() {
                    Boxy.get(this).setContent("<div style=\"width: 300px; height: 300px\">Sending...</div>");
                    // submit form by ajax using post and send 3 values: subject, your_email, comment
                    $.post("feedback.php", { subject: c.find("input[name='subject']").val(), your_email: c.find("input[name='your_email']").val(), comment: c.find("#comment").val()},
                    function(data){
                        /*set boxy content to data from ajax call back*/
                        contactBoxy.setContent("<div style=\"width: 300px; height: 300px\">"+data+"</div>");
                    });
                    return false;
                });
            }
        });
        return false;
    });
});

Open in new window

SOLUTION
Avatar of pg-expert
pg-expert
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial