我定义了一个这样的类:
var LoadingPolecy={
initialize:function(){
return function(){
this.initialize.apply(this,arguments);
}
}
}
var AjaxLoadingPolecy= LoadingPolecy.initialize();
AjaxLoadingPolecy.prototype={
initialize:function(name){
this.name=name;
},
AjaxStartPolecy : function(){
...
},
AjaxStopPolecy : function(){
...
},
SetName : function(name){
...
}
}
var TempLoadingPolecy=LoadingPolecy.initialize();
TempLoadingPolecy.prototype={
initialize:function(displayArea,source,data){
this.loadingMsgPolecy = new AjaxLoadingPolecy();
...
},
StartLoadingTempPolecy : function(callback){
this.loadingMsgPolecy.SetName('view');
this.loadingMsgPolecy.AjaxStartPolecy();
var a = $.ajax({
...
success:function(html){
callback(html);
}
});
},
EndLoadingTempPolecy : function(html){
//Cannot call method 'AjaxStopPolecy' of undefined error
this.loadingMsgPolecy.AjaxStopPolecy();
....
}
}
我似乎这个对象已经改变了,我怎样才能调用/使用我在初始化中定义的变量?