My rotating banner script is throwing a "Too much recursion" error when the iKeyless.widget.Rotator.rotate(); function is called within init();. I can't figure out why, init(); is only called once and there's a defer() on the second call.... when the page loads it lags before throwing "too much recursion"
return {
init: function () {
ui.container = $("#rotating-banner");
ui.thumbs = $("#rotating-banner .tabs .tab");
ui.banners = $("#rotating-banner .banner");
ui.fadeBox = $(".rotate .bd .fade-box");
ui.thumbs.each(function (idx, el) {
$(el).click(function () {
paused = true;
iKeyless.widget.Rotator.rotate.show(idx);
});
});
iKeyless.widget.Rotator.rotate();
},
show: function (idx) {
ui.fadeBox.css("display", "block");
ui.fadeBox.animate({
opacity: 1
},
.125,
function () {
$('.active', $(ui.banners[idx]).addClass('active').parent()).removeClass('active');
ui.fadeBox.animate({
opacity: 1
},
.125,
function () {
ui.fadeBox.css("display", "none");
});
});
},
rotate: function () {
if (!paused) {
this.show(counter);
counter = counter + 1;
if (counter === ui.thumbs.length) {
counter = 0;
}
iKeyless.widget.Rotator.rotate().defer(5000);
}
}
}
I think the issue is that you need to do this
iKeyless.widget.Rotator.rotate.defer(5000);
instead of this
iKeyless.widget.Rotator.rotate().defer(5000);
Source: When you write rotate(), you execute the function rotate and then execute defer. When you write rotate.defer() you are getting the function rotate, and using the method defer that is defined on Function.
Also, if this is jQuery, how do you have defer defined? I'm not sure jQuery provides a defer function. If this is Prototype, I don't think defer takes any arguments. Perhaps you want delay. Delay takes a time in seconds, so you'd want (assuming 5 seconds, not 5000 seconds):
iKeyless.widget.Rotator.rotate.delay(5);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With