I'm having problems when it comes displaying the timer in my page when using jcountdown via the rails-assets-pipeline
Error message: Uncaught TypeError: $(...).countdown is not a function
Code:
countdown_timer.js
$(document).ready(function(){
$("#timeleft").countdown({
"date" : "november 07, 2015"
});
});
view:
<div id="timeleft"></div>
I understand the error, but not knowing too much about javascript so I don't know how to fix it. I'm following the instructions as per their wiki page jcountdown
I removed the //= (*=)require jcountdown
from application.js
and application.scss
because unable to find stylesheets using turboliks
Now that we've successfully gotten the library to load,
replace
$(document).ready(function() {
$("#timeleft").countdown({
"date" : "november 07, 2015"
});
});
with
$(document).ready(function() {
$("#timeleft").countdown("2015/11/07");
});
For more information, i'd refer to the most up to date version of the docs here
EDIT:
There is a simple example given as well on the page, though I will repeat it here.
html
<div id="getting-started"></div>
and js
$("#getting-started")
.countdown("2016/01/01", function(event) {
$(this).text(
event.strftime('%D days %H:%M:%S')
);
});