jQuery startInterval and clearInterval in different functions

I am attempting to build a somewhat OOP jQuery plugin. Everything is going great, but I can’t seem to get the start/pause function to implement correctly. I have the following 2 functions:

this.startAutoPlay = function() {
    var interval = setInterval(function() { 
        obj.gotoNext(); 
    }, config.timing);
};

this.stopAutoPlay = function() {
    clearInterval(obj.startAutoPlay);
};

I just need a way to access the interval variable from within the stopAutoPlay function.

Any pointers?


Source: oop

Leave a Reply