[英]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>
類似於此頁面上記錄的內容,但未顯示任何內容。
我是否缺少明顯的東西? 謝謝你的幫助。
我設法再次顯示我的倒計時!
我發現(打印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.