This may sound weird but ive been banging my head for the past 2 hours because of this problem. I have a function that triggers once I press a login button, when pressed it starts an Ajax Request.
onEnter: function () {
Ext.Viewport.mask();
var email = Ext.getCmp('email').getValue();
var pass = Ext.getCmp('pw').getValue();
var consegui = 0;
Ext.Ajax.request({
controller: 'AP4.controller.MainCont',
url: 'myurl',
method: 'POST',
callbackKey: 'callback',
jsonData:{"username":'user', "password":'pass'},
success: function(result) {
//Se o webservice nao der erro ele entra aqui, nao quer dizer que tenha
//sido correctamente criado session
// Unmask the viewport
Ext.Viewport.unmask();
Ext.Msg.alert("Login Done! Congrats!");
Ext.Viewport.setActiveItem(this.getRegisto()); **//THIS LINE IS NOT WORKING**
},
failure: function(result){
Ext.Msg.alert("Username ou Palavra passe Incorrectas!");
},
});
},
For some reason, The setActiveItem is not working and I dont know why. Can anyone help me ?
i think you are accessing this.getRegisto;
function in wrong scope,
have you checked this
keyword points to the object which you want in the success callback?
to change the scope of success callback you can simply add scope
argument in the Ext.Ajax.request
call, like this
Ext.Ajax.request({
url: 'myurl',
method: 'POST',
success: function(result) {
// this will point to ViewPort object here
},
failure: function(result){
Ext.Msg.alert("Username ou Palavra passe Incorrectas!");
},
scope : Ext.Viewport // this is used just for illustration, please specify correct scope here
});
If Registo is in your viewport, why not use setActiveItem(some number) like if Registro is the first item in your viewport then do setActiveItem(0);