RailsCasts Pro episodes are now free!

Learn more or hide this

benmmurphy's Profile

GitHub User: benmmurphy

Comments by


that should be:


window.myvar == "<foo>"

one problem with using javascript tags is the 'j' escape function in rails doesn't work correctly or doesn't work how you might expect it to work. the string you send it is not always preserved and is corrupted in subtle ways.

for example if you have a string like:


and if you have:

<%= javascript_tag do %>
  window.myvar = '<%= j "<foo>" %>';
<% end %>

then window.myvar == "<foo>"

the j function really has to replace '<' and '>' with '\u003C' and '\u003E'.