Skip to content

Instantly share code, notes, and snippets.

@crissdev
Created August 30, 2015 12:35
Show Gist options
  • Save crissdev/b5bcd8b5442f5690a130 to your computer and use it in GitHub Desktop.
Save crissdev/b5bcd8b5442f5690a130 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Test page</title>
<meta http-equiv="X-UA-Compatible" content="IE=8"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.1.11/es5-shim.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/json2/20150503/json2.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-debug.js" type="text/javascript"></script>
<script src="https://cdn.rawgit.com/crissdev/knockout.mapping/master/dist/knockout.mapping.js" type="text/javascript"></script>
</head>
<body>
<pre data-bind="text: unwrappedValue"></pre>
<script type="text/javascript">
function Data() {
this.purchaseDate = ko.observable(new Date());
}
function ViewModel() {
this.data = ko.observable(new Data());
this.unwrappedValue = ko.observable('Test');
this.unwrappedValue(
ko.mapping.toJSON(this.data, null, null, 2)
);
}
setTimeout(function() {
ko.applyBindings(new ViewModel());
}, 100);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment