hoyhoy
hoyhoy

Reputation: 6351

How do I use escape_javascript with Rails 3.0.8 and beyond?

This is fixed in Rails 3.0.9 now. raw() is no longer necessary.

If you’re using js views and partial html replacements, Rails 3.0.8 is totally broken. Right after the 3.0.8 release, 3.0.9rc1 was released which partially addresses the problem.

Upvotes: 1

Views: 840

Answers (2)

hoyhoy
hoyhoy

Reputation: 6351

After upgrading, you have to wrap every escape_javascript call with raw() if you want your javascript to replace HTML. This was absolutely not the case with 3.0.7.

So, escape_javascript('<img src="lolcat.jpg" />') becomes raw(escape_javascript('<img src="lolcat.jpg" />')).

Upvotes: 3

Ryan Bigg
Ryan Bigg

Reputation: 107738

This will be fixed when this issue is solved: https://github.com/rails/rails/issues/1589

Upvotes: 0

Related Questions