Javascript Prototype Accessing Another Prototype Function
function Scroller(id){ this.ID = id; this.obj = $('#'+id); this.currentSlide = 1; var self = this; setInterval(self.nextSlide, 1000); } Scroller.prototype.nex
Solution 1:
When setInterval calls a function, it calls it with the context (or this value) of window (ie. it calls the function in the global scope/context). You need to make sure the context inside nextSlide is correct.
Try:
setInterval(self.nextSlide.bind(self), 1000);
Post a Comment for "Javascript Prototype Accessing Another Prototype Function"