I like to push my view model structures out to my View and then use those in javascript. What is a more elegant way to do this? These lines of code are kind of ugly.
<script type="text/javascript">
var PartChangeModel = @Html.Raw(Json.Encode(Model.PartChange));
var PartModel = @Html.Raw(Json.Encode(Model.Part));
var BOMItemModel = @Html.Raw(Json.Encode(Model.BOMItem));
</script>
Per suggestion from A-Dubb, I put this into an extension method. Which way makes more sense? Probably 6 and half dozen kind of thing.
Then you can call it from Razor like this: