tags:

views:

4029

answers:

1

I need to pause for maybe 500 miliseconds before I submit a form. Here is what I have so far:

 $(".rowqty input").bind("keyup", function() { $("#ViewCartPage form").animate({ opacity: 1.0 }, 3000).submit() });

so when someone changes the quantity of the input field it submits the form, but I want it to wait for a slight amount of time incase they need a moment to type 2 or 3 numbers.

As you can see I tried the animate function to try and delay things but with no luck.

I know I could use this: http://blog.mythin.net/projects/jquery.php

I'd rather not add another JS to my site if there is a way around it.

EDIT: Actually the pause plugin above is not working for me either.

+2  A: 

Give this a shot:

$(".rowqty input").bind("keyup", function() { setTimeout("$('#ViewCartPage form').submit()", 500 });
Chris Pebble
worked like a charm - funny how I don't even think about regular JS anymore - DOH!
Slee
Better to use a function than a string:$(".rowqty input").bind("keyup", function() { setTimeout( function() { $('#ViewCartPage form').submit() }, 500 });
Greg
thanks - code updated!
Slee
with 1.4 there is also the delay function that can be used. http://api.jquery.com/delay/
DMin