I've got my /umbraco/base posting working well...in fact too well! I want to delay the submit so the "pollsubmitting" message stays on the screen for 2 seconds.
$(function() { $(".submit").click(function(e){ jQuery("#poll").hide(); jQuery("#pollsubmitting").show(); jQuery("#poll .submit").attr("enabled", false); var url = "/base/Poll/SubmitAnswer/" + e.target.value + ".aspx"; var pollIdvar = jQuery(".poll #pollId").val(); -- PUT DELAY HERE -- jQuery.post(url, { pollId: pollIdvar }, function(data){ var a = null; } ); }); });
I've looked at .delay() and setTimeOut but can't get either to work.
$(function(){
$(".submit").click(function(e){
jQuery("#poll").hide();
jQuery("#pollsubmitting").show();
jQuery("#poll .submit").attr("enabled", false);
var url = "/base/Poll/SubmitAnswer/" + e.target.value + ".aspx";
var pollIdvar = jQuery(".poll #pollId").val();
setTimeout( function() { jQuery.post(url, { pollId: pollIdvar }, function(data){ var a = null; }); }, 2000 );
});
});
I haven't tested this, (obviously its set-up for your AJAX call), but I "think" that the values for "url" and "pollIdvar" should be stored within the closure - otherwise they may need to be declared as global variables. (I can already feel the evil looks from JS purists for suggesting that!)
Hmmm...your setTimeout syntax is exactly what I've tried before and it didn't work. I've used yours and also tried with global vars but all has the same result. Quick post and full page refresh.
How to delay a Base jquery submit
I've got my /umbraco/base posting working well...in fact too well! I want to delay the submit so the "pollsubmitting" message stays on the screen for 2 seconds.
I've looked at .delay() and setTimeOut but can't get either to work.
Any Jquery gurus out there wanting some karma?
Hi Trevor,
I'd go with a setTimeout...
I haven't tested this, (obviously its set-up for your AJAX call), but I "think" that the values for "url" and "pollIdvar" should be stored within the closure - otherwise they may need to be declared as global variables. (I can already feel the evil looks from JS purists for suggesting that!)
Cheers, Lee.
Hmmm...your setTimeout syntax is exactly what I've tried before and it didn't work. I've used yours and also tried with global vars but all has the same result. Quick post and full page refresh.
Do I need to somehow stop the "default" submit?
Any other ideas?
T
You need to stop the event - http://api.jquery.com/event.preventDefault/
Ahaaa - that was the little gem that I was missing. Thanks slace (and lee).
is working on a reply...