Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems passing special chars with observe_field
    primarykey
    data
    text
    <p>I am working on a rails project. Using the tag observe_field, I am taking text typed into a text area, processing it in a control, and displaying the result in a div (very similar to the preview in stack overflow). Everything works fine until I type certain special chars.</p> <ol> <li>? => causes the variable not to be found in the params object</li> <li>(pound) => causes an invalid authenticity error</li> <li>% => stops the div from being updated</li> <li>&amp; => every thing after the &amp; is no longer passed into the variable on the server. </li> </ol> <p>Is there a way to solve this?</p> <p>--- code sample ---</p> <p>this is the view. ( 'postbody' is a text area)</p> <pre><code>&lt;%= observe_field 'postbody', :update =&gt; 'preview', :url =&gt; {:controller =&gt; 'blog', :action =&gt; 'textile_to_html'}, :frequency =&gt; 0.5, :with =&gt; 'postbody' -%&gt; </code></pre> <p>this is the controller that is called</p> <pre><code>def textile_to_html text = params['postbody'] if text == nil then @textile_to_html = '&lt;br/&gt;never set' else r = RedCloth.new text @textile_to_html = r.to_html end render :layout =&gt; false end </code></pre> <p>and this is the javascript that is created:</p> <pre><code>new Form.Element.Observer('postbody', 0.5, function(element, value) {new Ajax.Updater('preview', '/blog/textile_to_html', {asynchronous:true, evalScripts:true, parameters:'postbody=' + value + '&amp;authenticity_token=' + encodeURIComponent('22f7ee12eac9efd418caa0fe76ae9e862025ef97')})}) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload