js.erb renders but does not execute
I cannot understand why this isn't working:
View:
<%= link_to disp, lookup_watch_index_path(:user => user, :cate => disp, :pos => 0), :remote => true %>
Controller:
def lookup
respond_to do |format|
format.js { render :content_type => 'text/javascript' }
end
end
js.erb file:
page.call 'leftScroll();'
The server tells me that the file wa开发者_运维知识库s rendered successfully, and the chrome console throws no errors. I get response code 200 OK, but nothing happens! Whats going on?
Edit:
When I use chrome console to view to response it looks like this:
page.call 'leftScroll();'
Does this mean its not generating the scripts properly perhaps? I wrote the ajax out by hand using jquery and it works fine, why is this not working with the rails rjs helper methods?
your js.erb file is going to render plain javascript so there's no need to use the prototype "page.call" anymore like in your old .rjs files. Pretty sure you should just be able to call:
leftScroll();
精彩评论