I have the following code which uses Jquery UI Drag and Drop. When the item is dropped into the area, the drop zone changes into the company logo, then I want a delay and a redirect to the URL within the dropped link.
I can get the logo to change OR the url to redirect but not both, when I have both setup the delay doesn't happen and the redirect goes start away. I assume I am doing something wrong with the setTimeout.
Code is as follows:
// let the trash be droppable, accepting the gallery items
$( "#droparea" ).droppable({
accept: "ul.gallery > li a",
activeClass: "ui-state-highlight",
drop: function( event, ui ) {
var thelink = $(ui.draggable).attr("href");
$('#droparea').prepend('<img id="theImg" src="../img/logo_navigation.jpg" />');
setTimeout(redirectLink(url),5000);
}
});
// URL REDIRECT FUNCTION
function redirectLink(url)
{
window.location.replace(url);
}