Posts Tagged ‘observe_field’
2nd April
2009
I was using the Rails helper observe_field to monitor a text entry form on my web app. I couldn’t figure out why the relevant method was not being called until I realized that it was happening every time there was a single quote in the text entry. The solution is simple. Use the escape_javascript function as shown below:
[ruby]
<%= observe_field :guess,
:frequency => 0.5,
:update => 'ajaxWrapper',
:url => {:action => 'feedback', :only_path => false},
:with => "'correct=#{escape_javascript(@text)}&guess='+encodeURIComponent(value)" %>
[/ruby]
0 Comments