is it a Ruby ? Rails ? or JS ? problem...

J

Josselin

In a Rails controller action, I am receiving a string parameter back
from an Ajax request


#using inline RJS (Remote JavaScript), I render html replacing a hidden
input field in a form
render :update do |page|
page.remove ('new_title')
page.insert_html:)after, 'hidden_values', "<INPUT TYPE=HIDDEN
id='new_title' NAME='new_title' VALUE='#{params[:new_title]}' />")
page.form.reset 'propform'
end

if there is no single quote in params[:new_title] = "John Doe is a
stupid and silly boy"
I get the full string as a value in the input field
but
if there is a single quote in params[:new_title] = "John Doe's sister
is a nice beautiful girl"
I get only ""John Doe"

where is the problem.. is theer anyway to avoid it ?

thanks

joss
 
J

Josselin

In a Rails controller action, I am receiving a string parameter back
from an Ajax request


#using inline RJS (Remote JavaScript), I render html replacing a hidden
input field in a form
render :update do |page|
page.remove ('new_title')
page.insert_html:)after, 'hidden_values', "<INPUT TYPE=HIDDEN
id='new_title' NAME='new_title' VALUE='#{params[:new_title]}' />")
page.form.reset 'propform'
end

if there is no single quote in params[:new_title] = "John Doe is a
stupid and silly boy"
I get the full string as a value in the input field
but
if there is a single quote in params[:new_title] = "John Doe's sister
is a nice beautiful girl"
I get only ""John Doe"

where is the problem.. is theer anyway to avoid it ?

thanks

joss

got it ! : I must write : VALUE=\"#{params[:new_title]}\"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,201
Messages
2,571,049
Members
47,652
Latest member
Campbellamy

Latest Threads

Top