Reputation: 668
I'm using Rails 3.1 and AJAX for creating some models.
The view looks like:
<%= link_to 'Vote', votes_path, :method => :post, :remote => true %>
And the controller:
...
def create
...
respond_to do |format|
format.js { render :layout => false }
end
end
...
Finally, the .js.erb looks like:
alert('Hi there!');
In Chrome, FF and Safari it works as I expected, creating the model and displaying the alert. In IE8, it creates the model but it doesn't execute javascript. I think its a weird problem with jquery-rails or something, because with Rails 3.0.9 it works well.
Thank you!
P.D. I also tried format.js { render :layout => false, :content_type => "text/javascript" }
but still doesn't work.
Upvotes: 2
Views: 1624
Reputation: 419
Does it also happen in other versions of Explorer, newer of older?
Have you debugged if the problem is at the time of performing the ajax call or when receiving it? Do you get any error report?
Are you including the csrf_meta_tags in the layout? They can really mess up things when performing a POST.
http://apidock.com/rails/ActionView/Helpers/CsrfHelper/csrf_meta_tag
I would advise you to use the Internet Explorer 8 debugger:
http://blogs.msdn.com/b/jscript/archive/2008/03/13/jscript-debugger-in-internet-explorer-8.aspx
Upvotes: 1
Reputation: 668
I just found the solution debugging jquery_ujs
remote calls. The problem was with charset response (I think).
For some reason I must specify explicitly:
format.js { render :layout => false, :content_type => "text/javascript; charset=UTF-8" }
Please, don't use IE8 :D
Upvotes: 0