Reputation: 1934
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
Reputation: 11896
Try changing the first line from
@CommentPoller ->
to
CommentPoller =
Upvotes: 1