syads321
syads321

Reputation: 11

Confusing about Jquery Timer

iam using jquery timer http://jquery.offput.ca/timers/ to create document in every 5 second and with pause and resume controlled button. here is my script :

$(function() { 
            $('.handler').load("../Pages/csFetchCustomer.ashx?");
            $('.controlled-interval').everyTime(5000, 'controlled', function() {
                $('.handler').load("../Pages/csFetchCustomer.ashx?");
                $('.stop').click(function() {
                    $('.controlled-interval').stopTime('controlled');
                });
            });
        });

with this script, i am already create document that load every 5 second with pause button controll,. but how to create resume / play button control ? any suggestion are welcome thanks.

Upvotes: 0

Views: 130

Answers (1)

WTK
WTK

Reputation: 16971

There's a working demo on their site that is doing what you want, but here's simplified code of mine:

$(document).ready(function() {
    var active = true,
        runLoadEvery = function() {
            $('.controlled-interval').everyTime(5000, 'controlled', function() {
                $('.handler').load("../Pages/csFetchCustomer.ashx?");                    
            });
        };
    // start running as soon as ready event is fired
    runLoadEvery();

    $('.start').click(function() {
        active = true;
        runLoadEvery();
    });
    $('.stop').click(function() {
        active = false;
        $('.controlled-interval').stopTime('controlled');
    });
});

Upvotes: 1

Related Questions