Hi, I have been working to modify a fading slideshow image gallery script w/ controls, but I am having problems deferring a function to run when the interpreter is idle using Prototype's defer() method. Here is a snippet of my code and I want to defer the showSlide() function: var slideshow = { currentSlide: 0, slides: $$('#slideimg li'), init: function(){ slideshow.slides[slideshow.currentSlide].show(); pe = new PeriodicalExecuter(slideshow.showNext, 5); $$('#slidebtn li').invoke('observe', 'click', function(e) { for(var i=0; i<$$('#slidebtn li').length; i++){ if(e.element().up(0) == $$('#slidebtn li')[i]){ if(slideshow.currentSlide !== i){ if(pe){ pe.stop(); slideshow.showSlide(i).defer(); pe = new PeriodicalExecuter(slideshow.showNext, 5); } } } } }); }, showSlide: function(slide){ $(slideshow.slides[slideshow.currentSlide]).fade(); $(slideshow.slides[slide]).appear(); slideshow.currentSlide = slide; } };
Basically, this is the error I get from firebug when I run slideshow.showSlide(i).defer(): slideshow.showSlide(i).defer() is undefined How can I defer the showSlide() function so that when users click on the buttons too quickly, it will wait for the interpreter to idle before attempting to run the showSlide() function again. I think I am on the right track in trying to use defer(), instead of queueing the effect to suppress events being fired too quickly. However, I don't know whether my use of defer() is correct. You can see a working demo here: http://icecreamcola.com/testing/ I have pasted the code in pastie.org: http://pastie.org/546795 Any help in the right direction would be most appreciated. - Paul K --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---