I saw inside the firebug.
The value of the field ("texto") is :

" example line 1 \r\n line 2 without enter \n line 3 with enter"

So I conclude that the "wrapped" lines return with "\r\n" mark.
No problem but my original function splits by "\n" mark:
lines = texto.split(/\n/).size if texto !=nil

But Oooooppppssss the result is again 2. Split function only work with "\n" mark alone. Do not when then "\n" mark have a folk mark "\r" by it side ? 

I am preparing to kill "\r" marks.....(only inside the "texto" field...)
Another suggestion ?

Colin Law escribió:
2009/7/31 Fabian <[email protected]>:
  
Colin:
Nothing for this field in the development.log
Do I set anythig special to log the template ?

    

In the log you should see something along the lines of this, but with
the data from your form in it.  This is extracted from my log.

Processing NotesController#create (for 127.0.0.1 at 2009-06-12 17:00:57) [POST]
  Parameters: {"commit"=>"Create", "note"=>{"date(1i)"=>"2009",
"date(2i)"=>"6", "date(3i)"=>"12", "max_present"=>"", "text"=>"Some
text", "obj_ids"=>["47", "85"], "location_id"=>"23",
"is_present"=>"1"}}

You are still top posting by the way.

Colin


  
Colin Law escribió:

2009/7/31 Fabian <[email protected]>:


HTML generated is:
<textarea id="aviso_texto" wrap="hard" style="" rows="20" name="aviso[texto]" cols="30"/>



That looks ok, have you looked in the log (log/development.log) to see
what is actually submitted?

Colin



Colin Law escribió:

2009/7/30 Fabian <[email protected]>:


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 ?


Have you checked the html generated (View, Page Source or similar in
browser) to check the option has been coded correctly?

Colin









    



  


--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to