Created
December 16, 2014 20:34
-
-
Save devdays/0cc31ca45f9e60949050 to your computer and use it in GitHub Desktop.
Object JavaScript - HTML File that uses an external template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Binding List to Template</title> | |
</head> | |
<body> | |
<h2>Products</h2> | |
<table id="target" | |
data-bind="template: { name: 'ProductTemplate', foreach: productArray }"> | |
</table> | |
<script src="Scripts/jquery-2.0.0.js"></script> | |
<script src="Scripts/knockout-2.2.1.debug.js"></script> | |
<script src="Scripts/TrafficCop.js"></script> | |
<script src="Scripts/infuser.js"></script> | |
<script src="Scripts/koExternalTemplateEngine.js"></script> | |
<script type="text/javascript"> | |
$(function () { | |
//infuser.defaults.templateUrl = "./templates"; | |
function ViewModel() { | |
this.productArray = ko.observableArray([ | |
{ product: "Widget", type: "Tool" }, | |
{ product: "Bolt", type: "Fastener" }, | |
{ product: "Washer", type: "Fastener" }, | |
{ product: "Screwdriver", type: "Tool" } | |
]); | |
} | |
ko.applyBindings(new ViewModel()); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment