Javascript Rails 4-计时器(jQuery.Countdown)
我正在尝试在我的Rails中创建一个计时器。但我得到了一个错误:Javascript Rails 4-计时器(jQuery.Countdown),javascript,jquery,ruby-on-rails,timer,Javascript,Jquery,Ruby On Rails,Timer,我正在尝试在我的Rails中创建一个计时器。但我得到了一个错误: jquery.countdown.min.self-6add0e5….js?body=1:7 Uncaught TypeError: Cannot read property 'createPlugin' of undefined 我补充说: jquery.countdown.min.jsintoassets/javascripts jquery.condown.cssintoassets/stylesheets jQuery
jquery.countdown.min.self-6add0e5….js?body=1:7 Uncaught TypeError: Cannot read property 'createPlugin' of undefined
我补充说:
intojquery.countdown.min.js
assets/javascripts
intojquery.condown.css
assets/stylesheets
是否存在并且工作正常jQuery.js
- 进入
-application.js
/=requirejquery.countdown.min
- 进入
-application.scss
*=需要jquery.countdown
<th width="20%" class="timeRem" data-countdown-until="<%= 10.days.from_now %>"></th>
不知道如何修复它,非常感谢任何建议和帮助。根据我们的评论,
jquery.countdown.min.js
文件应该放在jquery.min.js
之前,jquery.countdown.min.js
文件应该放在jquery.min.js
页面上的脚本顺序是jquery.js
然后jquery.plugin.js
然后jquery.countdown.js
[
ref:您将脚本按以下顺序放置在页面上
jquery.js
然后jquery.plugin.js
然后jquery.countdown.js
[
ref:jquery.countdown.min.js是否出现在你的渲染页面中的
jquery.min.js
之后?是的,我通过先排序插件js,然后倒计时解决了这个问题。添加它作为未来谷歌的答案。是否jquery.countdown.min.js
出现在你的渲染页面中的jquery.min.js
之后?是的,我解决了这个问题通过先订购插件js,然后再订购倒计时..为未来的谷歌用户添加了一个答案。
Timers =
init: ->
@initCountdownUntil()
@initCountdownSince()
initCountdownUntil: ->
$('[data-countdown-until]').each (index, element) ->
$element = $(element)
date = new Date($element.data('countdown-until'))
$element.countdown(until: date)
initCountdownSince: ->
$('[data-countdown-since]').each (index, element) ->
$element = $(element)
date = new Date($element.data('countdown-since'))
$element.countdown(since: date)
window.Timers = Timers