无为清净楼资源网 Design By www.qnjia.com
复制代码 代码如下:
function actsAsDecorator(object) {
object.setupDecoratorFor = function(method) {
if (! ('original_' + method in object) ) {
object['original_' + method] = object[method];
object['before_' + method] = [ ];
object['after_' + method] = [ ];
object[method] = function() {
var i;
var b = this['before_' + method];
var a = this['after_' + method];
var rv;
for (i = 0; i < b.length; i++) {
b[i].call(this, arguments);
}
rv = this['original_' + method].apply(this, arguments);
for (i = 0; i < a.length; i++) {
a[i].call(this, arguments);
}
return rv;
}
}
};
object.before = function(method, f) {
object.setupDecoratorFor(method);
object['before_' + method].unshift(f);
};
object.after = function(method, f) {
object.setupDecoratorFor(method);
object['after_' + method].push(f);
};
}
/**
Invoking
*/
function Test(){
this.say1 = function(s){
alert(s);
}
this.say2 = function(s){
alert(s);
}
}
var t = new Test();
actsAsDecorator(t);
t.before("say1",beforeHander);
t.after("say2",afterHander);
test();
标签:
ajax回调函数

无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com