TAT.melody 一种简单的实现自定义事件的方法
In 未分类 on 2011年12月09日 by view: 4,085
4

原创文章转载请注明:

转载自AlloyTeam:http://www.alloyteam.com/2011/12/%e4%b8%80%e7%a7%8d%e7%ae%80%e5%8d%95%e7%9a%84%e5%ae%9e%e7%8e%b0%e8%87%aa%e5%ae%9a%e4%b9%89%e4%ba%8b%e4%bb%b6%e7%9a%84%e6%96%b9%e6%b3%95/

  1. laohe 2012 年 10 月 24 日

    var Events = {
    bind: function () {
    if ( !this.o ) {
    this.o = $({});
    }
    this.o.bind.apply(this.o, arguments);
    },

    trigger: function() {
    if ( !this.o ) {
    this.o = $({});
    }
    this.o.trigger.apply(this.o, arguments);
    }
    };

    你可以参照这个思路,也许会倒腾出更简单的。

  2. F 2012 年 5 月 15 日

    哥们,handlers.splice(i) 在 fire fox 下把所有的 handler 都删掉了,囧。

  3. F 2012 年 5 月 15 日

    此段代码 IE8 不兼容
    removeEventListener 方法失败,必须写成 handlers.splice(i,1); 才可删除 handler

    • azrael 2012 年 5 月 15 日

      嗯, 谢谢校正

发表评论到 F