ExtJs textarea multiline issue
Asked Answered
C

3

6

How can I assign text containing \r\n to an ExtJs textarea and get to see line breaks instead of the actual \r\n characters? When I manually press the Enter key and check Firebug, I can see \r\n getting inserted. But if I assign a string containing \r\n to the textarea, it renders as-is.

Any hints would be helpful.

Crystie answered 15/6, 2010 at 9:44 Comment(0)
C
5

I solved it myself. I was using the 'html' property to assign the \r\n-riddled text to the textarea. I changed that to 'value', and it works like a charm. Thanks anyway.

Crystie answered 18/6, 2010 at 10:30 Comment(0)
D
0

Try:

var text = text.replace('\r\n',"" + String.fromCharCode(13) + String.fromCharCode(10));
Destrier answered 16/6, 2010 at 14:41 Comment(0)
K
0

Try this:

Replace all occurrences of \r\n with \n globally. g - represents replace all occurrences of \r\n with \n and it will move to the next line.

var formattedText=text.replace(/\\n/g,'\r\n');
Ext.ComponentQuery.query('#id')[0].setValue(formattedText);
Kacykaczer answered 10/4, 2019 at 19:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.