繁体   English   中英

Ruby on Rails-jQuery.countdown不显示

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

在我转向RoR之前,我使用了很棒的jQuery倒计时功能 ,并且运行良好。 我尝试在我的Rails(4.0.8)应用程序中再次使用它,但是我不知道为什么什么也没显示。

我在app / assets / javascripts中(还有其他):

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

在我的application.js中:

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

在我的Gemfile中:

gem 'jquery-rails', '3.0.4'

在我的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>

类似于此页面上记录的内容,但未显示任何内容。

No_display_countdown

我是否缺少明显的东西? 谢谢你的帮助。

我设法再次显示我的倒计时!

我发现(打印javascript控制台)错误$ is not defined 因此,我从Gemfile中删除了gem'jquery gem 'jquery-rails', '3.0.4'并执行了命令gem uninstall jquery-rails 然后,我在标题中添加了几行,然后重新启动了服务器。

<%= 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