I need to pass one of the values of my model to the jsrender function. I tried using @ to access a C # variable, but not working. Below is my code
<script type="text/x-jsrender" id="TemplateDate">>
{{:~formatTemplateDate(Model.EstimatedCompletionDate)}}
</script>
This is my helper function.
$.views.helpers({
formatTemplateDate: function (dateEstimated) {
"use strict";
if (dateEstimated !== null) {
if (!isSafari) {
var options = {
year: "numeric",
month: "short",
day: "numeric",
hour: "2-digit",
minute: "2-digit"
};
return dateEstimated.toLocaleTimeString("en-us", options);
} else {
return dateEstimated;
}
} else {
return null;
}
}
});
This is the error I get on the page
Error: n.toLocaleDateString is not a function.
Thanks in advance.
Dinesh.
source
share