简体   繁体   English

Rails - 防止textarea忽略空格/特殊字符

[英]Rails - prevent textarea from ignoring whitespace/special characters

I have the following string being output into a textarea as a variable in my view. 我在视图中将以下字符串作为变量输出到textarea中。 It's an AJAX call and I can see via the response that the spaces are being passed through. 这是一个AJAX调用,我可以通过响应看到空间正在通过。 However, all the whitespace is ignored in my textarea. 但是,我的textarea中忽略了所有空格。 How can I prevent this? 我怎么能阻止这个?

"status": "success",
"matches": "1",
"results":
    {
        "id": "56342", 
        "call_date": "2011-08-24 00:00:00",
        "tracking_number": "12223334444",
        "ringto_number": "12223334444",
        "direction": "inbound",
        "duration": "127",
        "file_url": "http://www.logmycalls.com/recordings/somesound.mp3",
        "reviewer": "admin@myaccount.com",
        "scorer": "user@myaccount.com",
        "score_grade": "87",
        "score_outcome": "pass",
        "status": "active"
    }
]

This is what it looks like in the textarea: 这就是textarea中的样子:

[
"status": "success",
"matches": "1",
"results":
{
"id": "56342", 
"call_date": "2011-08-24 00:00:00",
"tracking_number": "12223334444",
"ringto_number": "12223334444",
"direction": "inbound",
"duration": "127",
"file_url": "http://www.logmycalls.com/recordings/somesound.mp3",
"reviewer": "admin@myaccount.com",
"scorer": "user@myaccount.com",
"score_grade": "87",
"score_outcome": "pass",
"status": "active"
}
]

Css属性:

white-space: pre;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM