I have a bar that shows up (in rails) from a flash hash. I want it to explode with jquery, so I added this code:
<script>
setTimeout("derp()", 2000);
function derp() {
$("span").hide("explode", { pieces: 16 }, 500);
}
</script>
Works fine except in a couple of seconds it appears again and then something extremely strange happens – the path to googleapis is shown and the page becomes barely responsive. What gives?
This is the proper way of using setTimeout
running it the way you had is like using eval(), you should avoid passing a string in setTimeout()
you could also pass your function like this: