Jseb
Jseb

Reputation: 1934

Polling change on rails with railscasts revised

I am trying to follow polling for change but i get the following error

Uncaught TypeError: Object [object global] has no method CommentPoller

Here the code in my comment.js.coffee file

# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

@CommentPoller ->
  poll: ->
    setTimeout @request, 5000

  request: ->
    $.get($('#comments').data('url'))

jQuery ->
  if $('#comments').length > 0
    CommentPoller.poll()

What i am doing wrong? Thank you

Upvotes: 0

Views: 340

Answers (1)

Alex Blakemore
Alex Blakemore

Reputation: 11896

Try changing the first line from

@CommentPoller ->

to

CommentPoller =

Upvotes: 1

Related Questions