Stop setInterval within jQuery plugin
- by Romelus
I am trying to wrap up a plugin that I am writing but am stumped on a very trivial problem that I cant seem to find a solution for. I have tracked down almost every forum and related problem discussion. Any ways here is what I want to happen, my plugin has a timer that I would like the user to be able to handle its termination.
(function ($) {
...
var defaults = {
callback : function(){},
crossfadeTime : 1000,
easing : 'linear',
running : 'true', // Here is where I would like the user to send a parameter
// to invoke a different result. i.e. 'false' => clearing
// the timer. Such as...
var timer = setInterval(function(){
// Do Something;
},3000);
if(defaults.running == 'false'){
clearInterval(timer);
}