开发者

How to preserve line breaks in Scriptaculous InPlaceEditor?

I have a page with various textareas which can be edited using Scriptaculous (is there a better option?):

<h4>
    <span id="someID">
        <开发者_JAVA百科;?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 />?


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. ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜