liborza
liborza

Reputation: 1009

Rails 4 - Timer (jQuery.Countdown)

I'm trying to create a timer into my Rails. But I'm getting this error:

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

I add :

Then i create:

VIEW

<th width="20%" class="timeRem" data-countdown-until="<%= 10.days.from_now %>"></th>

timer.js.coffee

 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

Don't rally know how to fix it, appreciate any advice and help with that.

Upvotes: 0

Views: 2492

Answers (2)

lasec0203
lasec0203

Reputation: 2683

You place the scripts on the page in this order jquery.js then jquery.plugin.js then jquery.countdown.js

[]

ref: http://keith-wood.name/countdown.html

Upvotes: 2

Uzbekjon
Uzbekjon

Reputation: 11823

As per our comments, jquery.countdown.min.js file should be placed before jquery.min.js.

Upvotes: 1

Related Questions