Skip to content

Instantly share code, notes, and snippets.

@jasondentler
Created June 22, 2011 19:00
Show Gist options
  • Save jasondentler/1040832 to your computer and use it in GitHub Desktop.
Save jasondentler/1040832 to your computer and use it in GitHub Desktop.
The Pieces
<html>
<head>
<title>@ViewBag.Title</title>
<!-- various css and javascript includes go here -->
@if (Model != null)
{
<script type="text/javascript">
model = @Model.ToJson();
</script>
}
</head>
<body>
<!-- Static HTML page header stuff goes here -->
@RenderBody()
<!-- Static HTML footer stuff goes here -->
</body>
<script type="text/javascript">
model = @Model.ToJson();
</script>
<script type="text/javascript">
model = {"Id": "4", "FirstName": "John", "LastName": "Smith"};
</script>
[HttpGet, ImportModelState]
public ActionResult Details(Guid Id)
{
return Request.IsAjaxRequest()
? (ActionResult) Json(GetDetailsModel(Id), JsonRequestBehavior.AllowGet)
: View(GetDetailsModel(Id));
}
[HttpPost, ExportModelState]
public RedirectToActionResult AddItem(AddItem model)
{
ExecuteCommand(model)
return this.RedirectToAction(c => c.Details(model.Id));
}
@model Index
@{
ViewBag.Title = "Instructors";
Html.RegisterTemplate("instructorListTemplate", "Templates/instructorList.tmpl.html");
}
<script id="template" type="text/html">
{{tmpl "#instructorListTemplate"}}
<h2 class="hint">Choose an instructor from the left</h2>
</script>
<div data-bind='template: "template"' />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment