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

'Uncaught TypeError: $(...).countdown is not a function' - may be correct! #341

Open
paskainos opened this issue Nov 25, 2022 · 0 comments

Comments

@paskainos
Copy link

TL;DR: jquery.countdown and jquery-countdown are different repos. Save yourself hours, be sure to install jquery-countdown not jquery.countdown.

Simply stated: .countdown is not defined in jquery.countdown, rather, it is camel case, i.e. .countDown. Thus, Uncaught TypeError: $(...).countdown is not a function is the correct outcome / output if one is after TFC, but has erroneously installed jquery.countdown instead of jquery-countdown. So, if one has 'done everything right' and yet remains flummoxed (e.g. 'why won't this silly package update past v1.2.8...??') odds are, this is the culprit.

Having used this handy dandy library in the past, but not for some time, and battling this dread error again, I would be remiss not to clearly, once and for all, briefly articulate the precise nature of the exact error by which so many have undoubtedly been led astray. It is simply this:

It is the difference between the "." and the "-". jquery.countdown and jquery-countdown are two different libraries. The instructions -- at The Final Countdown - jQuery.countdown page, for instance -- do not make that distinction clear, in fact leading to the error. The libraries are inadvertently somewhat comingled throughout the docs and issues, such that jquery.countdown is being pulled down, and jquery-countdown is being called. So, one must make sure to install jquery-countdown and not jquery.countdown.

For the record, [email protected] and [email protected] (latest, currently, for jQuery v2.2.0) work. So for example, with them installed (in that order, obviously, and correct paths called) this:

<div id="christmas-countdown"></div>

works with this:

<script type="text/javascript">
  $("#christmas-countdown")
  .countdown("2022/12/25", function(event) {
    $(this).text(
      event.strftime('%D days %H hrs %M min %S sec')
    );
  });
</script>

And require('jquery-countdown') is not 'required' (unnecessary). I hope that helps someone down the line -- perhaps even me... next time...

P.S. Sorry about the book. It was catharsis...

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

1 participant