Skip to content

Instantly share code, notes, and snippets.

@sagacity
Created November 3, 2010 12:27
Show Gist options
  • Save sagacity/661026 to your computer and use it in GitHub Desktop.
Save sagacity/661026 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://knockoutjs.com/js/jquery.tmpl.js" type="text/javascript"></script>
<script src="http://knockoutjs.com/js/knockout-latest.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
var model = {
prop: ko.observable(1)
};
model.change = function() {
model.prop(model.prop() + 0);
}
model.prop.subscribe(function(newValue) {
alert("Prop changed");
});
ko.applyBindings(model);
});
</script>
<div data-bind="text: prop"></div>
<button data-bind="click: change">Change</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment