Javascript 作为回调的自定义小部件中的call函数

Javascript 作为回调的自定义小部件中的call函数,javascript,dojo,Javascript,Dojo,我试图从函数SetLoginInfo内部调用widget Login中的函数SetLoginButtonLabel——SetLoginInfo是来自widget LogInDB的回调。当我尝试仅使用this.SetLoginButtonLabel调用它时,我得到错误SetLoginButtonLabel未定义。我也在尝试如下所示的挂接,但这也不起作用。我想从SetLoginInfo调用几个不同的函数——如何使用hitch或其他方法来实现这一点 谢谢 ---小部件登录 ... postCreate

我试图从函数SetLoginInfo内部调用widget Login中的函数SetLoginButtonLabel——SetLoginInfo是来自widget LogInDB的回调。当我尝试仅使用this.SetLoginButtonLabel调用它时,我得到错误SetLoginButtonLabel未定义。我也在尝试如下所示的挂接,但这也不起作用。我想从SetLoginInfo调用几个不同的函数——如何使用hitch或其他方法来实现这一点

谢谢

---小部件登录

...
postCreate: function() {
 var SetLab = lang.hitch(this, "SetLoginButtonLabel");

}

Login: function() //call the database
{

LoginDB.Login("http://xxx/John Smith", this.SetLoginINfo)
},


SetLoginInfo: function(LoginData) //call back from LoginDB
{
//I've tried:
this.SetLogingButtonLabel("status"); //get an undefined error

//and 
SetLab("Logout");//this just seems to get lost

},

SetLoginButtonLabel: function(status)
{
//
}

.......
---小部件登录

define(['dojo/store/Memory', 'dojo/_base/xhr', "dojo/data/ObjectStore", 'dojo/_base/json'],
//functions to get data and fill data stores
function (Memory, xhr, ObjectStore) {
    var TicketStore;
    return {
        //login
        Login: function (url, callback) {
            xhr.get({//send data
                url: url,
                handleAs: "json",
                load: function (result) {
                    var LoginData = result;
                    callback(LoginData);

                },
                error: function (err) { }

            });
        }



    }

});
这使它发挥了作用:

LoginDB.Login(s, lang.hitch(this, this.SetLoginInfo));
我在SetLoginInfo中的所有呼叫都在前面放了一个this:

this.SetLoginButtonLabel("Logged In");

我还试着像这样调用DB小部件:LoginDB.Login(s,lang.hitch(this.SetTOC));仍然会得到未定义的错误,而是:LoginDB.Login(s,lang.hitch(this,SetTOC));这确实有效:LoginDB.Login(s,This.SetLoginInfo,lang.hitch(This,This.SetLoginButtonLabel));然而,我想在上面的注释中调用setLoginIfoSetTOC中的一组函数应该是SetLoginInfo(我在帖子中更改了函数名)