I'm having trouble with a index.js.erb which I've create but isn't execuing. I have the following in my controller:
def index
@images = Image.order('id desc')
respond_to do |format|
format.js
format.html
end
end
And the following in my index.js.erb:
alert("it works")
If this helps as well I have the following in my coffee script file for this project:
ImagePoller =
poll: ->
setTimeout @request, 5000
request: ->
$.get($('#images').data('url'))
jQuery ->
if $('#images').length > 0
ImagePoller.poll()
I can tell the js.erb file isn't load because I'm not seeing the alert? Any ideas?
/images.js? If you want Rails to render your 'index.js.erb', your url have to request with.jsformat.