Wednesday, November 14, 2012

[Rails] How to stop ruby escaping javascript?

Hi all.

If In my view I have:

<%= text_field_tag('name','',:onfocus => "for (var i=1;i<99999;i++){};"
%>

I'd expect to have this html:

<input name="name" onfocus="for (var i=1;i<99999;i++){};" />

instead I have:

<input name="name" onfocus="for (var i=1;i&lt;99999;i++){};" />

And obviously the javascript code does not work...

I also tried this:
<%= text_field_tag('name','',:onfocus => "for (var
i=1;i<99999;i++){};".html_safe %>

but the output is the same

Thanks to all.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate