-
-
Save GraemeF/1507159 to your computer and use it in GitHub Desktop.
Broken Knockout
This file contains hidden or 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> | |
<body> | |
<form data-bind="submit: onSubmit"> | |
<button type="submit">Submit</button> | |
</form> | |
<script type="text/javascript" src="knockout-2.0.0.js"></script> | |
<script type="text/javascript"> | |
window.onload = function () { | |
var viewModel = { | |
onSubmit : function(formElement) { | |
alert('works'); | |
} | |
}; | |
ko.applyBindings(viewModel); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It wasn't loading the knockout library due to language attribute (I changed it to type, but it works if you remove it altogether too shrug), and it was trying to apply bindings to the DOM before the DOM was loaded (you could put that bit in your JQuery startup bit instead if you're also using that).