Thanks for the quick reply!!
OK that's a step in the right direction but there is still something I
am doing wrong!
My postback data is incorrect. I tried unwrapping the object that was
mapped but still get the same result. The follow is the post data
being sent back to the server:
"userLoginViewModel=%7B%22__ko_mapping__%22%3A%7B%7D%7D"
This is what I am actually doing:
<!DOCTYPE html>
<html>
<head>
<title>Logon</title>
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-1.4.4.min.js" type="text/
javascript"></script>
<script src="/Scripts/jquery.tmpl.js" type="text/javascript"></
script>
<script src="/Scripts/knockout-1.1.2.js" type="text/javascript"></
script>
<script src="/Scripts/knockout.mapping.js" type="text/
javascript"></script>
</head>
<body>
<h2>Logon</h2>
<div data-bind="data : viewModel">
<form data-bind="submit: postUserLoginViewModel" action="/User/
Login" >
<ul data-bind="template: { name : 'loginTemplate', data :
userLoginViewModel }"></ul>
<button type="submit">Login</button>
</form>
</div>
<script type="text/html" id="loginTemplate">
<li><label for="UserName"></label><input type="text" id="UserName"
data-bind="value: UserName"/></li>
<li><label for="Password"></label><input type="password"
id="Password" data-bind="value: Password"/></li>
<li><label for="Persist"></label><input type="checkbox"
id="Persist" data-bind="checked: Persist"/></li>
</script>
<div data-bind="template : { name : 'loginTemplate', data :
viewModel } "></div>
<script type="text/javascript">
var userLoginViewModel =
{"UserName":"Mike","Password":"password","Persist":true};
var viewModel = {
userLoginViewModel : ko.mapping.fromJS(userLoginViewModel),
postUserLoginViewModel : function() {
ko.utils.postJson(location.href, { userLoginViewModel:
this.userLoginViewModel });
}
};
ko.applyBindings(viewModel, document.body);
</script>
</body>
</html>