简体   繁体   English

Ruby on Rails-jQuery.countdown不显示

[英]Ruby on Rails - jQuery.countdown no display

Before I move to RoR I was using this great jQuery countdown and it worked fine. 在我转向RoR之前,我使用了很棒的jQuery倒计时功能 ,并且运行良好。 I try to use it again in my Rails (4.0.8) application but I can't figure it why nothing is displayed. 我尝试在我的Rails(4.0.8)应用程序中再次使用它,但是我不知道为什么什么也没显示。

I have in app/assets/javascripts (among others) : 我在app / assets / javascripts中(还有其他):

application.js
jquery.countdown.min.js
jquery-2.1.1.min.js

In my application.js : 在我的application.js中:

//= require_tree .
//= require jquery-2.1.1.min
//= require jquery.countdown.min

In my Gemfile : 在我的Gemfile中:

gem 'jquery-rails', '3.0.4'

In my app/views/pages/page.html.erb : 在我的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. 类似于此页面上记录的内容,但未显示任何内容。

No_display_countdown

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 . 我发现(打印javascript控制台)错误$ is not defined So I remove gem 'jquery-rails', '3.0.4' from my Gemfile and perform the command gem uninstall jquery-rails . 因此,我从Gemfile中删除了gem'jquery gem 'jquery-rails', '3.0.4'并执行了命令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" %>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM