alex3 Posted August 6, 2009 Share Posted August 6, 2009 I have a function that loops through a particular type of page element and repositions each instance of it. This function is supposed to be called after a time out, but I keep getting a function undefined error in Firebug (and, of course, the timeout does nothing). Here's the two pieces of script The function: function rePosition() { for (i=0; i<totalRows; i++) { var clientNumber = i + 1; ZeroClipboard.clients[clientNumber].reposition(); } } And the timeout part: $.post( 'actions/delete.php', { filename:fileName }, function(data) { if(data=='yes') { ZeroClipboard.clients[rowNumber].destroy(); img.hide(); parentRow.css({opacity:'100'}).animate({opacity:0},1000).hide('fast'); setTimeout("rePosition()", 1500); } else { alert('Failed to delete file. Please contact support. ' + data);} } ); rePosition() is defined before the .post function, and the totalRows variable is defined before anything, so I really cannot see the problem here. If I included the if statement inside the setTimeout, it doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/169142-solved-defined-function-apparently-isnt-defined/ Share on other sites More sharing options...
Maq Posted August 6, 2009 Share Posted August 6, 2009 Can you post the entire error? Quote Link to comment https://forums.phpfreaks.com/topic/169142-solved-defined-function-apparently-isnt-defined/#findComment-892393 Share on other sites More sharing options...
alex3 Posted August 6, 2009 Author Share Posted August 6, 2009 Sure. From Firebug: rePosition is not defined index.js()index.js (line 78) [break on this error] setTimeout("rePosition()", 1500);\n Quote Link to comment https://forums.phpfreaks.com/topic/169142-solved-defined-function-apparently-isnt-defined/#findComment-892398 Share on other sites More sharing options...
roopurt18 Posted August 6, 2009 Share Posted August 6, 2009 Been a while since I used setTimeout, but I think you can leave off the parens: setTimeout("rePosition", 1500); Or you could possibly just pass the function reference: setTimeout(rePosition, 1500); Quote Link to comment https://forums.phpfreaks.com/topic/169142-solved-defined-function-apparently-isnt-defined/#findComment-892415 Share on other sites More sharing options...
alex3 Posted August 6, 2009 Author Share Posted August 6, 2009 I am afraid not :/ This is really perplexing me; it's right there! Quote Link to comment https://forums.phpfreaks.com/topic/169142-solved-defined-function-apparently-isnt-defined/#findComment-892486 Share on other sites More sharing options...
alex3 Posted August 15, 2009 Author Share Posted August 15, 2009 Hum. I'm too sure what solved it, but after a bit of kerjiggering the timeout now works, using the aforementioned setTimeout(rePosition, 1500) method. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/169142-solved-defined-function-apparently-isnt-defined/#findComment-898784 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.