As I posted earlier, I want to count lines in a text area.
I use the following function
lines = texto.split(/\n/).size if texto !=nil

But fails when one line of text "wraps" automatically to the next line so no "\n" mark is returned into the text.

So i found the "wrap" attribute of textareas that works this way:
  • soft
  • hard
  • off

Soft forces the words to wrap once inside the text area but when the form is submitted, the words will no longer appear as such (Line breaks will not be added).

Hard wraps the words inside the text box and places line breaks at the end of each line so that when the form is submitted it appears exactly as it does in the text box.

Off sets a textarea to ignore all wrapping and places the text into one ongoing line.

So I insert it in my txtarea definition like this:

<%= f.text_area :texto, :cols => "30" , :style => "whiteSpace:pre-line;", :wrap => "hard" %>


Nothig happens. The count line was the same.
Any suggestions ?
FF


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to