Suggestion from CBroe worked. But, in a Rails way,
<%= text_field_tag "answer_name",truncate(answer.name,:length=>35), :onfocus => "this.blur();", :style=>"cursor:default;", :readonly => true%>
It worked. Don't forget to put the CSS line 'cursor: default;' will change the pointer to arrow type as by default, a text box will have text-mode pointer (The pointer type that you can see while putting answer in SO through this area).
This won't work in IE
. So, better replace the text_field
with div
element and make the text_field a hidden field
to carry out the opeartions.
Thank you all. :)