question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Event "finish.countdown" dont working

See original GitHub issue

Hello, I am trying to display an alert on a page that contains 3 countdown. The alert is to be displayed when any of them is finalized. But nothing happens when I use “finish.countdown”. It simply resets the counter. I tested the event “update.countdown” and worked well. I’m missing something? Below is my code. thank you

HTML CODE

<div data-countdown="2015-14-10 09:00:00"></div>
<div data-countdown="2015-14-10 10:00:00"></div>
<div data-countdown="2015-14-10 11:00:00"></div>

JAVASCRIPT CODE

$('[data-countdown]').each(function() {
  var $this = $(this), finalDate = $(this).data('countdown');

  $this.countdown(finalDate, function(event) {
    $this.html(event.strftime('%H:%M:%S'));
  });

  $(this).on('finish.countdown', function(event){
    alert("teste");
  });
});

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
hilioscommented, Oct 16, 2015

With the legacy approach one will handle all events in a single callback (update, finish or stop) through the event.type property […] Source: http://hilios.github.io/jQuery.countdown/documentation.html#introduction

Try not to use the legacy callback with a registered event, the suggested approach is to bind each event one like to handle:

$('[data-countdown]').each(function() {
  var $this = $(this), finalDate = $(this).data('countdown');

  $this.countdown(finalDate)
  $this.on('update.countdown', function(event){
    $this.html(event.strftime('%H:%M:%S'));
  });
  $this.on('finish.countdown', function(event){
    alert("teste");
  });
});
0reactions
nonatocommented, Oct 24, 2015

Hello Hilios, I found out what had happened. It was a small mistake I made. The date format was wrong. When I changed the string that shows the counter to show how many days were lacking for the event, I saw that there were still many days. For this reason, the counter back to 23:59:00 when reached 00:00:00. In fact, he was reduced one day to the event. I was using the format: YYYY-DD-MM. But I should have used: YYYY-MM-DD. After correcting this, everything worked properly. Thank enough for their commitment to help me. Thank you so much. Big hug

Read more comments on GitHub >

github_iconTop Results From Across the Web

jquery countdown event on finish did not show intended html
I have been doing jquery countdown process with two date parameters. But when second date parameters end, the html intended did not show...
Read more >
Timer.finish event does not trigger automation - Configuration
The automation can be run manually (obviously) but the timer never triggers it (not when it finishes the end of its countdown, and...
Read more >
WHY IS THERE A COUNTDOWN TIMER IN FORTNITE? (THE ...
The new live event is going to be called the end live event because ... the countdown timer for, countdown You are not...
Read more >
Show a countdown to an event in your ad
Not everyone can show a countdown to an event in their multimedia ads yet. ... Countdown ends: Select the date and enter the...
Read more >
How to Add a Countdown Timer in Your Email - Stripo
Add customizable countdown timers to your emails within just two minutes. ... be somewhat confusing — hard to understand what time exactly the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found