Open madelyncruz opened 7 years ago
Ditto to this! It would be great to be able to destroy a timer.
Hi, anyone know how to destroy countdown instance?
https://github.com/hilios/jQuery.countdown/issues/118#issuecomment-110462678
<button class="start">start</button>
<div id="clock"></div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.countdown/2.2.0/jquery.countdown.min.js" ></script>
<script type="text/javascript">
$(function(){
$('.stop').click(function(){
$('#clock').countdown('remove');
$('#clock').empty();
})
$('.start').click(function(){
var fiveSeconds = new Date().getTime() ;
$('#clock').countdown(fiveSeconds, {elapse: true})
.on('update.countdown', function(event) {
var $this = $(this);
if (event.elapsed) {
$this.html(event.strftime('<span class="time-countup">%H:%M:%S</span>'));
}
});
})
})
</script>```
Hello,
First of all, thank you for this useful library. It's definitely a big help.
Is there a way to destroy .countdown on ajaxStop? At the moment, the timer still running even though I put it on an if else statement.
I am currently using this on a product which has variations and running via ajax.
Product 1 = No timer Product 2 = Has timer
Clicking Product 2 is OK as it has timer set. The timer still running after clicking product 1. I would like hide the timer element / destroy it when product has no timer set.
I've tried to alert a message and it's working properly based on the condition set. It's just the timer is still running even though Product 1 has no timer set.
Here is the sample code:-
if (condition == true) {
$(target).countdown('2017/06/30 12:00 am', function(event) {
// render starts here.
});
}
Please help.....