Before I move to RoR I was using this great jQuery countdown and it worked fine. I try to use it again in my Rails (4.0.8) application but I can't figure it why nothing is displayed.
I have in app/assets/javascripts (among others) :
application.js
jquery.countdown.min.js
jquery-2.1.1.min.js
In my application.js :
//= require_tree .
//= require jquery-2.1.1.min
//= require jquery.countdown.min
In my Gemfile :
gem 'jquery-rails', '3.0.4'
In my app/views/pages/page.html.erb :
<br />
--
<div data-countdown="2016/01/01"></div>
--
<script type="text/javascript">
$('[data-countdown]').each(function() {
var $this = $(this), finalDate = $(this).data('countdown');
$this.countdown(finalDate, function(event) {
$this.html(event.strftime('%D days %H:%M:%S'));
});
});
</script>
Like documented on this page but nothing shows up.
Am I missing something obvious ? Thanks for your help.
I managed to display my countdown again !
I found (printing the javascript console) that I have the error $ is not defined
. So I remove gem 'jquery-rails', '3.0.4'
from my Gemfile and perform the command gem uninstall jquery-rails
. Then I added those few lines in my header and restarted the server.
<%= javascript_include_tag "jquery-2.1.1.min" %>
<%= javascript_include_tag "jquery.countdown.min" %>