knockoutjs:Example 1: hasfocusの基本型:hasfocus binding

  1. <!DOCTYPE html>
  2. <html lang="ja">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>knockoutjs:Example 1: hasfocusの基本型:hasfocus binding</title>
  6. <script type="text/javascript" src="jquery-1.5.1.min.js"></script>
  7. <script type="text/javascript" src="knockout-2.1.0beta.js"></script>
  8. </head>
  9. <body>
  10. <h1>knockoutjs:Example 1: hasfocusの基本型:hasfocus binding</h1>
  11. <input data-bind="hasfocus: isSelected" />
  12. <button data-bind="click: setIsSelected">Focus programmatically</button>
  13. <span data-bind="visible: isSelected">The textbox has focus</span>
  14. <script type="text/javascript">
  15.   var viewModel = {
  16.     isSelected: ko.observable(false),
  17.     setIsSelected: function() { this.isSelected(true) }
  18.   };
  19.   
  20.   ko.applyBindings(viewModel);
  21. </script>
  22. <div style="font-size:10pt;text-align:right;margin-top:0.5em;">
  23. <a href="//tips.recatnap.info/" target="_top">PCスキルの小技・忘却防止メモ</a> -
  24. <a href="//tips.recatnap.info/wiki/" target="_top">PCスキルの小技・忘却防止メモのまとめ(wiki)</a>
  25. </div>
  26. <div style="font-size:10pt;text-align:center;margin-top:0.5em;padding:0.5em;border-top:1px solid #ccc;">
  27. Copyright &copy; 2009 by PCスキルの小技・忘却防止メモ. All rights reserved.
  28. </div>
  29. </body>
  30. </html>