views:

52

answers:

1

I am working on this piece of code using the jQuery Countdown Plugin it works but how ever if i try using a function with " function showPauseTime ()" I keep getting an error showPauseTime undefined.

Can any body take a look at the code and tell me how I could solve this thanks

$('#beginExercise').click(function() {
    //check if terms checkbox is checked before stating timer                              
    if($('#terms').is(':checked')){ 

            $("#pauseButton").show();

            //start time at zero
            $("#elapsTimer").countdown({since: 0,onTick:showPauseTime});

             //Allow the Elaps Timer to be paused
            $('#pauseButton').toggle(function() { 
                    $(this).text('Resume Exercise'); 
                    $('#elapsTimer').countdown('pause'); 
                }, 
                function() { 
                    $(this).text('Pause Exercise'); 
                    $('#elapsTimer').countdown('resume'); 
            }); 

            function showPauseTime(periods) { 
                $('#showPauseTime').text(periods[4] + ':' + twoDigits(periods[5]) + 
                    ':' + twoDigits(periods[6])); 
            }

     } //end if         
});
A: 

Can you just keep the function : showPauseTime(periods){...} outside of the 'Click' event and then try again?

Also the function is expecting a parameter : periods, which was not supplied in the function call, i guess.

Siva Gopal
ok I tried it outside the click function it seems to be working but now i getting an other error "twoDigits is not defined"also can you explain to me to the parameter periods not o familiar with it
Oudin
I figured it out got it to work the "twoDigits" was being used but was not defined how ever if you can explain the parameter : periods that would be helpfull
Oudin
I am sorry for the delay in my reply, Oudin. In fact, i just suggested you by examining your code. But i am sorry that i don't have hands on the plug-in. You can please take a look at the plug-in code, for how it is being used internally. If i get time, for sure i will let you know about the parameter : periods.
Siva Gopal
And here is the answer for your question from the plug-in website: The array of current countdown periods (int[7] - based on the format setting) is passed as a parameter: [0] is years, [1] is months, [2] is weeks, [3] is days, [4] is hours, [5] is minutes, and [6] is seconds.
Siva Gopal
But please mark the answer, if it solve your problem. :-)
Siva Gopal