Stop setInterval within jQuery plugin
Posted
by
Romelus
on Stack Overflow
See other posts from Stack Overflow
or by Romelus
Published on 2010-12-26T05:09:50Z
Indexed on
2010/12/26
5:54 UTC
Read the original article
Hit count: 249
jQuery
|setinterval
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);
}
© Stack Overflow or respective owner