-1
我想调用小部件中的函数SetLoginButtonLabel从函数内部登录SetLoginInfo - SetLoginInfo是从小部件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)
{
//
}
.......
---小部件LoginDB
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) { }
});
}
}
});
我也尝试调用DB小部件是这样的: LoginDB.Login(S,lang.hitch(this.SetTOC)); 仍然得到未定义的错误 – pvitt 2014-09-25 23:22:59
而是它是这样的: LoginDB.Login(s,lang.hitch(this,SetTOC)); – pvitt 2014-09-25 23:30:38
这是行不通的: LoginDB.Login(s,this.SetLoginInfo,lang.hitch(this,this.SetLoginButtonLabel)); 但是我想从setLoginIfo调用一堆函数 – pvitt 2014-09-29 16:43:01