开发者

jQuery submit form after effect is complete?

I'm trying to use jQuery's queue() to show() a div prior to submitting a form. However my current code just immediately submits the form before the show() effect even starts. BTW #savebutton is not a submit element, just an image with this click ev开发者_JAVA技巧ent.

$("#savebutton").click(function () {
    $("#saving").queue(function()
    {
        $("#saving").show("slow");
        $("#form1").submit();
    });
});

How can I make sure the show() completes before submitting?

Thanks for any advice!!


You could use show(speed, callback) function:

$('#savebutton').click(function () {
    $('#saving').show('slow', function() {
        $('#form1').submit();
    });
});


LOL, had the queue assigned to the wrong id. Corrected code works:

$("#savebutton").click(function () {
    $("#savebutton").queue(function()
    {
        $("#saving").show("slow");
        $("#form1").submit();
    });
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜