Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Destroy using if else statement #272

Open
madelyncruz opened this issue Jun 27, 2017 · 3 comments
Open

Destroy using if else statement #272

madelyncruz opened this issue Jun 27, 2017 · 3 comments

Comments

@madelyncruz
Copy link

madelyncruz commented Jun 27, 2017

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.....

@andreasantarl
Copy link

Ditto to this! It would be great to be able to destroy a timer.

@v4irajvimu
Copy link

Hi, anyone know how to destroy countdown instance?

@plonknimbuzz
Copy link

#118 (comment)

  <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>```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants