Created
November 3, 2010 12:27
-
-
Save sagacity/661026 to your computer and use it in GitHub Desktop.
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
<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