这是我的代码

当我从应用程序中显式调用getPreloadedAppList
preLoadedApp.getPreloadedAppList(successCallback1,failCallback1);
我得到正确的答复,为nApps = 12

但是当我使用enyo类型的create函数执行此操作时,我的程序被卡在那里。

enyo.kind({
name:'PreApp',
PreloadedApp : [],
nApps : 0,
Response:function(){
    this.onSuccess='';
    this.onFailure='';
    this.id = 0;
},
create: function(){
        this.inherited(arguments);
        this.init();
},
getPreloadedAppList: function(getListSuccessCallback,getListFailCallback){
    var param = new this.Response();
    param.onSuccess = getListSuccessCallback;
    param.onFailure = getListFailCallback;
    hcap.preloadedApplication.getPreloadedApplicationList(param);
},
launchPreloadedApp: function(launchSuccessCallback,launchFailCallback,id){
    var param = new this.Response();
    param.id = id;
    param.onSuccess = launchSuccessCallback;
    param.onFailure = launchFailCallback;
    hcap.preloadedApplication.launchPreloadedApplication(param);
},
init : function(){
    var suuccessCB = function(param){
        this.nApps = param.list.length;
        for (var i = 0; i < this.nApps; i++) {
            this.PreloadedApp.push(param.list[i]);
        }
    }
    var failureCB = function(param){
        alert("Failure " + param.errorMessage);
    }
    this.getPreloadedAppList.apply(this,[suuccessCB,failureCB]);
}
});


我想念什么?

最佳答案

我猜你需要像这样绑定您的successCB函数:

init : function(){
var suuccessCB = this.bindSafely(function(param){
    this.nApps = param.list.length;
    for (var i = 0; i < this.nApps; i++) {
        this.PreloadedApp.push(param.list[i]);
    }
})
var failureCB = this.bindSafely(function(param){
    alert("Failure " + param.errorMessage);
})
this.getPreloadedAppList.apply(this,[suuccessCB,failureCB]);


}

10-02 21:06