Skip to content

Instantly share code, notes, and snippets.

@kakikubo
Created February 9, 2016 13:10
Show Gist options
  • Save kakikubo/5fb085cfd3dcc2c67b7e to your computer and use it in GitHub Desktop.
Save kakikubo/5fb085cfd3dcc2c67b7e to your computer and use it in GitHub Desktop.
knockout.jsの簡単なサンプル。enable binding
<html>
<head>
<script src="./knockout.js"></script>
</head>
<body>
<p>
<input type="checkbox" data-bind="checked: hasCellphone" />
携帯電話をもっている
</p>
<p>
電話番号:
<input type='text' data-bind="value: cellphoneNumber, enable: hasCellphone"/>
</p>
<script type="text/javascript">
var viewModel = {
hasCellphone : ko.observable(false),
cellphoneNumber : ""
};
ko.applyBindings(viewModel);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment