2014-09-25 66 views
0

在我移動到RoR之前,我使用了這個很棒的jQuery countdown,它工作正常。 我嘗試在我的Rails(4.0.8)應用程序中再次使用它,但我無法確定爲什麼沒有顯示任何內容。Ruby on Rails - jQuery.countdown沒有顯示

我在app /資產/ JavaScript的(其中包括):

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> 

documented on this page但沒有任何顯示。

No_display_countdown

我失去了一些東西明顯?謝謝你的幫助。

回答

0

我設法再次顯示我的倒計時!

我發現(打印javascript控制檯),我有錯誤$ is not defined。所以我從我的Gemfile中刪除gem 'jquery-rails', '3.0.4'並執行命令gem uninstall jquery-rails。然後,我在標題中添加了這幾行,然後重新啓動服務器。

<%= javascript_include_tag "jquery-2.1.1.min" %> 
<%= javascript_include_tag "jquery.countdown.min" %>