如何在 Scriptaculous InPlaceEditor 中保留换行符?
我有一个包含各种文本区域的页面,可以使用 Scriptaculous 进行编辑(有更好的选择吗?):
<h4>
<span id="someID">
<?php echo $_SESSION['someID']; ?>
</span>
</h4>
PHP 文件如下所示:
<?php
if(!isset($_SESSION['someID']))
$_SESSION['someID'] = "Some text which spans more than <br />one line of a textarea";
?>
当我单击该元素并它变成一个文本区域,存在换行符。但是,当文本区域失去焦点并恢复到原来的任何元素时,换行符就会丢失。
有没有办法保留换行符?我应该以某种方式使用 \n
而不是
吗?
I have a page with various textareas which can be edited using Scriptaculous (is there a better option?):
<h4>
<span id="someID">
<?php echo $_SESSION['someID']; ?>
</span>
</h4>
The PHP file looks like so:
<?php
if(!isset($_SESSION['someID']))
$_SESSION['someID'] = "Some text which spans more than <br />one line of a textarea";
?>
When I click on the element and it becomes a textarea, the line breaks are present. However, when the textarea loses focus and goes back to being whatever element it was, the line breaks are lost.
Is there a way to preserve the line breaks? Should I be somehow using \n
instead of <br />
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确切地说 - 在
如果将其更改为
\r\n
它将起作用。为什么要额外添加
\r
?例如,在 Windows/IE/etc 中,简单的\n
是不够的。 ;)Exacly - in
<textarea>
break line tag<br/>
is treated as a text.If you change it to
\r\n
it will works.Why additional
\r
? For example in Windows/IE/etc simple\n
is not enough. ;)