首页 > Web开发 > 详细

Knockout.js hasFocus

时间:2015-08-17 18:44:50      阅读:182      评论:0      收藏:0      [点我收藏+]
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="js/jquery-1.11.1.min.js"></script>
    <script src="js/knockout-3.3.0.js"></script>
    <script type="text/javascript">

        function PersonViewModel(name) {
            // Data
            this.name = ko.observable(name);
            this.editing = ko.observable(false);

            // Behaviors
            this.edit = function () { this.editing(true) }
        }

        $(function () {
            ko.applyBindings(new PersonViewModel("Bert Bertington"));
        })
    </script>
</head>
<body>
    <p>
        Name: 
    <b data-bind="visible: !editing(), text: name, click: edit">&nbsp;</b>
        <input data-bind="visible: editing, value: name, hasFocus: editing" />
    </p>
    <p><em>Click the name to edit it; click elsewhere to apply changes.</em></p>
</body>

 

Knockout.js hasFocus

原文:http://www.cnblogs.com/YuanSong/p/4737033.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!