I am attempting to pass the data (type = string) from my MVC model to a javascript funcion but I keep getting an error "Uncaught SyntaxError: Unexpected token ILLEGAL". I believe this is caused by the newlines in the model data as it only occurs with multi-line strings.
The idea is for the user to press the "undo" button/link to reset the text area.
Image:

CSHTML:
@Html.TextAreaFor(model => Model.updates[i].body, new { @Class = "txtTextArea floatLeft", @Id = "Edit_" + i.ToString(), @style = "width: 70%;", @Rows = "4", @Cols = "30" })
<a class="textRight EditToLink" onclick="clearInput('[email protected]()', '@Html.Raw(Model.updates[i].body)')" id="[email protected]()" href="#" >undo</a>
Javascript Function:
function clearInput(input, val) {
if (document.getElementById(input) != null) {
if (val != null) {
val.replace(/\r?\n/g, "\r\n");
document.getElementById(input).value = val;
}
else {
document.getElementById(input).value = "";
}
}
}
Similar Question: http://forums.asp.net/t/1741372.aspx?pass+model+parameter+to+javascript+function
Thanks is advance!