Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/448.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Rails 4-计时器(jQuery.Countdown)_Javascript_Jquery_Ruby On Rails_Timer - Fatal编程技术网

Javascript Rails 4-计时器(jQuery.Countdown)

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

我正在尝试在我的Rails中创建一个计时器。但我得到了一个错误:

jquery.countdown.min.self-6add0e5….js?body=1:7 Uncaught TypeError: Cannot read property 'createPlugin' of undefined
我补充说:

  • jquery.countdown.min.js
    into
    assets/javascripts
  • jquery.condown.css
    into
    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