码迷,mamicode.com
首页 > Web开发 > 详细

js的delegate回调例子

时间:2014-07-07 17:42:40      阅读:193      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   文件   cti   

暂时没发现有具体的实际用处,先记录下

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>

</body>
</html>

<script>

    var CCaller =
    {
        createNew: function()
        {
            var instance = {};

            instance.delegate = null;
            instance.call = function(x)
            {
                if ( null != instance.delegate)
                {
                    instance.delegate.interfaceFuncImpl(x);
                }
            };

            return instance;
        }
    };

    var CInterfaceFuncImpl = {

        createNew: function()
        {
            var instance = {};

            instance.interfaceFuncImpl = function(arg)
            {
                alert(arg);
            };

            return instance;
        }
    };

    $(document).ready(function() {

        caller = CCaller.createNew();
        testImpl = CInterfaceFuncImpl.createNew();
        caller.delegate = testImpl;
        caller.call("asdasdasd");
    });

</script>

 

js的delegate回调例子,布布扣,bubuko.com

js的delegate回调例子

标签:style   blog   http   color   文件   cti   

原文地址:http://www.cnblogs.com/ziyouchutuwenwu/p/web.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!