Skip to content

Instantly share code, notes, and snippets.

@devdays
Created December 16, 2014 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devdays/e9c6c62f58bf06aaaab6 to your computer and use it in GitHub Desktop.
Save devdays/e9c6c62f58bf06aaaab6 to your computer and use it in GitHub Desktop.
Object JavaScript - Knockout Control Flow using with binding
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<h1 data-bind="text: product"></h1>
<p data-bind="with: warehouse">
Warehouse Location: <span data-bind="text: location"></span>,
Quantity Available: <span data-bind="text: quanAvail"></span>
</p>
<script src="Scripts/knockout-2.2.1.debug.js"></script>
<script type="text/javascript">
ko.applyBindings({
product: "Widget",
warehouse: {
location: "3D1",
quanAvail: 6
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment