The Session is preserved during HCR, so you could try syncing the text field up with a Session variable. Example:
<template name="textArea">
<textarea>{{textAreaValue}}</textarea>
</template>
Template.textArea.helpers({
textAreaValue: function () {
return Session.get("textAreaValue") || "";
}
});
Template.textArea.events({
"input textarea": function (evt) {
Session.set("textAreaValue", evt.currentTarget.value);
}
});
Note that this will cause the textArea
template to rerun after every character is typed. With Blaze this shouldn't be too much of a problem, but if you want to prevent this, use Deps.nonreactive
:
textAreaValue: function () {
return Deps.nonreactive(function() {
return Session.get("textAreaValue") || "";
});
}
Although then you won't be able to update the text area with Session.set("textAreaValue", ...)