-
14 Sep 2010 6:40 AM #1
How catch (and replace) carriage returns in a Ext.form.TextArea value
How catch (and replace) carriage returns in a Ext.form.TextArea value
Hi all,
I have a normal Ext.form.TextArea who saves its data into a normal mysql database.
When I load the text into the TextArea all is fine: the carriage returns are hidden, but they exists because the text is splitted into lines.
My problem is to show that text into a web page, but mantaining the text format, so the carriage returns must be ideally replaced by a <br/>.
[start of the example]
TEXT IN MY TEXTAREA:
---------------------------
Hallo,
this is my foo text.
Do you like it?
SAME TEXT, SHOWN IN A WEBPAGE
----------------------------------------
Hallo, this is my foo text. Do you like it?
[end of the example]
Someone can suggest me the right way to operate? Thanks!
-
14 Sep 2010 6:46 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
When exactly do you want to replace carriage returns with <br/>s?
ps. You can use the Ext.util.Format.nl2br function to do this.
-
14 Sep 2010 6:59 AM #3
Hi Condor,
thanks in advance for your fast suggestion!
I want to replace it at a PHP level, so maybe I must do this:
1. add a new field to the db table, named "html_description" (current one is named simply "description")
2. add a "onblur" listener to the textarea which fills a hidden input of the form, named "html_description"
3. save the normal text in the "description" field of the db table, and the html text in the "html_description" (using your suggestion), so the first text will be used always in the textarea and the 2nd in the web pages
-
14 Sep 2010 7:17 AM #4
Just set up a renderer?Code:function ta_renderer(v) { return Ext.util.Format.nl2br(v); } ... { dataIndex: whatevID, type: 'string', editor: new Ext.form.TextArea({ allowBlank: false, ... }), renderer: ta_renderer, ... } ...
Wes
-
15 Sep 2010 2:12 PM #5
Thank you darthwes.
I chose to add a "keypress" listener to the textarea, who fills a hidden field of the form with the text formatted by Ext.util.Format.nl2br function.
Many thanks,
MicheleWeb per vocazione
Similar Threads
-
Replace textarea with Ext.form.TextArea
By UnarmedHunter in forum Ext 3.x: Help & DiscussionReplies: 4Last Post: 26 Oct 2009, 1:00 AM -
catch enter in Ext.form.TextArea and active defaultbutton in form
By mdissel in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 6 Sep 2008, 6:17 AM -
disable catch or carriage return for formPanel
By mxu in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 7 Jan 2008, 1:26 PM -
carriage returns in textarea not encoded
By sj137 in forum Ext 1.x: Help & DiscussionReplies: 1Last Post: 15 May 2007, 3:12 AM



Reply With Quote