Knockout.js: How to bind a div width/height to form
http://stackoverflow.com/questions/5610689/knockout-js-how-to-bind-a-div-width-height-to-form-fields
HTML
<script src="https://github.com/jquery/jquery-tmpl/raw/master/jquery.tmpl.js"></script>
<script src="https://github.com/SteveSanderson/knockout/raw/master/build/output/knockout-latest.debug.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.11/themes/base/jquery-ui.css">
<div data-bind="foreach:Zones">
<div class="container" data-bind="style:{ top: ZoneY, left: ZoneX }, text: ZoneTest"></div>
</div>
CSS
.container { position: absolute; font-size: .75em; }
JavaScript
ko.applyBindings({
Zones: ko.observableArray([
{
ZoneX: 100,
ZoneY: 100,
ZoneTest: "hello world"
},
{
ZoneX: 200,
ZoneY: 200,
ZoneTest: "rage!"
}
])
});