我正在尝试跟踪轮询更改,但我收到以下错误
Uncaught TypeError: Object [object global] has no method CommentPoller
这是我的comment.js.coffee文件中的代码
# 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()
我做错了什么? 谢谢
答案 0 :(得分:1)
尝试更改第一行 从
@CommentPoller ->
到
CommentPoller =