Hello Guys,
Last time when i was playing with double spaces.. found the interesting thing. When passing the double space string from javascript (view) to controller , it converts the valid space to non-breaking space.
Lets see the eg.
View: index.rhtml
a = "This is the pen"
a.gsub(" ", " &nsbsp;")
<script language='javascript/text'>
/* Now assign the value to input element by */
$('txtid').value = <%= a %>;
// Get value back encodeURIComponent($('txtid'))
</script>
at controller
def any_method
# replace '\xC2\xA0' or ' ' with ' '
params[:a].gsub("\xC2\xA0", " ").gsub(" ", " ")
end
Hope above article is helpful to you guys.
For more info follow: http://www.javascripter.net/faq/mathsymbols.htm
No comments:
Post a Comment