The simplest way to do this is to use the setTimeout method (straight JS)
and give it an anonymous function as callback to trigger after given period.

Something like this should do the trick :

$('a.delayed').click(function() { // assuming these links all share the
"delayed" class
var clicked = $(this); // when setTimeout calls your anonymous function,
"this" will point to something else entirely

setTimeout(function () {
window.location.href = clicked.attr('href'); // assuming you want to go
wherever the link points to
}, 1000);

return false; // to prevent default action to be immediately triggered
});

Hope it helps.

Michel Belleville



2010/1/4 david.vansc...@gmail.com <david.vansc...@gmail.com>:
> I've been searching high and low on Google over the last hour looking
> for this, but can't seem to find anything.  Maybe I'm using the wrong
> search terms, but I'd think what I'm trying to accomplish is something
> that's been done before.
>
> What I'm looking to do is delay the action of a click for a set period
> of time.  I have a list of links for download zip archives and when
> you click on one of those links, I use the BlockUI plugin to show an
> overlay with a message that tells the user their download will start
> momentarily.  The reason this is done is so that I can fire off an
> AJAX event that inserts a record into a database for download
> tracking.  Ideally what I'd like to do is fire the AJAX event (which
> should only take about .2 seconds to run) and then wait for 2 or 3
> seconds before unblocking the UI and *then* letting the default action
> of the click (offering up the zip archive) fire.
>
> Any ideas how I might accomplish something like this?
>

Reply via email to