hilios/jQuery.countdown

html() is ignored

OvalMedia opened this issue · 1 comments

I am using jquery-2.1.4. (Although 1.11.1 yielded the same result).

<div id="clock"></div>

jQuery(document).ready(function ($) {
   $('#clock').countdown('2020/10/10', function(event) {
        $(this).html(event.strftime('%D days %H:%M:%S'));
        console.log(event.strftime('%D days %H:%M:%S'));
    });
});

The html() function is completely ignored while console.log() works fine, the time gets logged every second as expected.

No errors in the console or anything.

It gets even weirder. For the fun of it I put in an alert into the function:

jQuery(document).ready(function ($) {
   $('#clock').countdown('2020/10/10', function(event) {
        $(this).html(event.strftime('%D days %H:%M:%S'));
        alert(event.strftime('%D days %H:%M:%S'));
    });
});

It doesn't matter what the alert displays but with each alert window #clock actually gets displayed and updated all of a sudden. Of course this is not a solution but maybe it helps find the issue?

Might be related: #220

I got it working by using a completely different element as the target. The html() function should not modifiy the countdown() element.