does jquery have an equivalent of dojo.hitch()?

前端 未结 7 1689
甜味超标
甜味超标 2021-02-07 07:24

Forgive my ignorance as I am not as familiar with jquery. Is there an equivalent to dojo.hitch()? It returns a function that is guaranteed to be executed in the given scope.

7条回答
  •  别跟我提以往
    2021-02-07 08:11

    No. Not in 1.3.2, at least, as I don't know about 1.4. There are, however, some plugins:

    (function($) {
      $.fn.hitch = function(ev, fn, scope) {
        return this.bind(ev, function() {
          return fn.apply(scope || this, Array.prototype.slice.call(arguments));
        });
      };
    })(jQuery);  
    

提交回复
热议问题