PDA

View Full Version : Question about timing and events



pepepong
9 Jul 2012, 8:04 AM
Hi guys, this extjs newbie needs a hint ...

I'm currently making a wizard using the 'card' element. I have 3 different buttons that help the user to navigate trougth the different steps of the wizard.

The thing is that in certain steps I want to validate the data that was supplied by the user when he hits the Next button.

My problem is that the 'success' event in the submit is not processing the call to the doMoveFordward function and I don't really know why. Can you give me a hand ? what documentation do suggest me to follow in order to understand more about the events ?

Thanks in advance guys



doMoveFordward: function(){
var cardlayout = this.form.getLayout();
this.index++;
cardlayout.setActiveItem(this.index);
},

next: function(){
this.backBtn.show();
if(this.index < this.form.items.length-1){
if(this.index == 2){
this.form.getForm().submit({
url: 'handler.php',
method: 'POST',
success: function(form, action) {
this.doMoveFordward(); <------- PROBLEM
},

failure: function(form, action) {
Ext.MessageBox.show({title: 'Error', msg: 'Error in step 2', buttons: Ext.MessageBox.OK,icon: Ext.MessageBox.ERROR});
}});
}else{
this.doMoveFordward();
}

if(this.index == this.form.items.length-1){
this.nextBtn.hide();
this.finishBtn.show();
}
}
},

bt_bruno
9 Jul 2012, 8:45 AM
I think you're missing scope:this.


this.form.getForm().submit({
url: 'handler.php',
method: 'POST',
scope: this, //<--- fix scope problem
success: function(form, action) {
this.doMoveFordward();
},
failure: function(form, action) {
Ext.MessageBox.show({title: 'Error', msg: 'Error in step 2', buttons: Ext.MessageBox.OK,icon: Ext.MessageBox.ERROR});
}
});

pepepong
9 Jul 2012, 9:07 AM
I solved it using var formContext = this.form.getLayout(); at the beginning of the function but anyway I'm gonna try your solution

Thanks again