开发者

jQuery submit form after effect is complete?

开发者 https://www.devze.com 2022-12-13 02:29 出处:网络
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

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

精彩评论

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