Using this strips my newLine characters
Is there an alternative to this that will render html?
function viewCommentToggle( comment )
{
theRow = document.getElementById("id"+comment.id);
idx = 2;
// Comment field
cell = theRow.cells[idx];
while( cell.childNodes.length > 0 ) cell.removeChild(cell.childNodes[0]);
element = document.createTextNode(comment.comment);
cell.appendChild(element);
}
This is what Im concered with:
element = document.createTextNode(comment.comment);
just a fyi….this is what I did and it worked:
function viewCommentToggle( comment )
{
theRow = document.getElementById("id"+comment.id);
idx = 2;
// Comment field
//cell = theRow.cells[idx];
// while( cell.childNodes.length > 0 ) cell.removeChild(cell.childNodes[0]);
cell = $("#id"+comment.id+" > td:eq("+idx+")");
$(cell).empty();
$(cell).html( comment.comment == null ? "" : comment.comment.replace(/\n/g,"<br/>").replace(/\r/g,"") );
Newlines are only significant (AFAIK) within a
<pre>block.Outside of that, to force line breaks you’ll have to split your string into separate lines and then create a text node followed by a
<br/>for each one, i.e. something like:See http://jsfiddle.net/alnitak/WFTD6/