knockoutjs:Example 1: inputのenable(有効化):The enable binding

  1. <!DOCTYPE html>
  2. <html lang="ja">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>knockoutjs:Example 1: inputのenable(有効化):The enable binding</title>
  6. <script type="text/javascript" src="knockout-2.1.0beta.js"></script>
  7. </head>
  8. <body>
  9. <h1>knockoutjs:Example 1: inputのenable(有効化):The enable binding</h1>
  10. <p>
  11.   <input type='checkbox' data-bind="checked: hasCellphone" />
  12.   I have a cellphone
  13. </p>
  14. <p>
  15.   Your cellphone number:
  16.   <input type='text' data-bind="value: cellphoneNumber, enable: hasCellphone" />
  17. </p>
  18. <script type="text/javascript">
  19.   var viewModel = {
  20.     hasCellphone : ko.observable(false),
  21.     cellphoneNumber: ""
  22.   };
  23.   ko.applyBindings(viewModel);
  24. </script>
  25. <div style="font-size:10pt;text-align:right;margin-top:0.5em;">
  26. <a href="//tips.recatnap.info/" target="_top">PCスキルの小技・忘却防止メモ</a> -
  27. <a href="//tips.recatnap.info/wiki/" target="_top">PCスキルの小技・忘却防止メモのまとめ(wiki)</a>
  28. </div>
  29. <div style="font-size:10pt;text-align:center;margin-top:0.5em;padding:0.5em;border-top:1px solid #ccc;">
  30. Copyright &copy; 2009 by PCスキルの小技・忘却防止メモ. All rights reserved.
  31. </div>
  32. </body>
  33. </html>