Created
October 22, 2010 06:52
-
-
Save tristanz/640071 to your computer and use it in GitHub Desktop.
Problem binding functions with variables within a 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
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-latest.min.js"></script> | |
<script src="http://nje.github.com/jquery-tmpl/jquery.tmpl.js"></script> | |
<script src="http://github.com/downloads/SteveSanderson/knockout/knockout-1.1.0.js"></script> | |
</head> | |
<body> | |
<div data-bind="template: 'myTemplate'"></div> | |
<script id="myTemplate" type="text/html" > | |
<a href="#" data-bind="click: function () { alert(${ i }) }">Alert</p> | |
</script> | |
<script> | |
$(document).ready(function() { | |
viewModel = { | |
i : ko.observable(47), | |
}; | |
ko.applyBindings(viewModel); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment