-
4 Dec 2008 5:04 AM #1
[SOLVED] too much recursion with event valid/invalid and isvalid function
[SOLVED] too much recursion with event valid/invalid and isvalid function
Hello,
I'm trying to toggle a button if textfield event is valid or not !
Some textfield:
Here is the check function :PHP Code:
F_email_from = new Ext.form.TextField({
plugins: [new Ext.ux.FieldReadOnlyPlugin()]
,vtype:'email'
,fieldLabel: 'Expediteur'
,anchor : '100%'
,listeners:{
valid:function(){
btn_email_go_check();
}
,invalid:function(){
btn_email_go_check();
}
}
F_email_to = new Ext.form.TextField({
plugins: [new Ext.ux.FieldReadOnlyPlugin()]
,vtype:'email'
,fieldLabel: 'Destinataire(s)'
,anchor : '100%'
,listeners:{
valid:function(){
btn_email_go_check();
}
,invalid:function(){
btn_email_go_check();
}
}
});
});
So, what i want to do is: if one all events valid change, i make a sum check of all with is Valid() to toggle yes or no the button.PHP Code:function btn_email_go_check(){
if(F_email_from.isValid() && F_email_to.isValid()){
btn_email_go.enable();
} else {
btn_email_go.disable();
}
}
here is Firebug message:
Does isValid fire valid event ???too much recursion
[IMG]chrome://firebug/content/blank.gif[/IMG] if(l.fireFn.apply(l....this.obj||window, arguments) === false){

I don't really understand where i'm wrong.
Thanks !Last edited by stevanovich; 4 Dec 2008 at 6:12 AM. Reason: [SOLVED]
-
4 Dec 2008 5:09 AM #2
isValid calls validateValue.
validateValue calls markInvalid in certain cases.
markInvalid fires the invalid event.
So yeah, don't do that
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
4 Dec 2008 5:26 AM #3
Much more elements
Much more elements
Thanks evant !
My Log was full very quickly
!!!
Have you any suggest for toggle button with some valid events ?
other wise the other way for me is to check when press button , but the first is much pretty
Thanks
-
4 Dec 2008 6:10 AM #4
If someone is interested
If someone is interested
What i've done for going on:
First, i've make a byte of Validate, call .valide
And hope ExtJs will never use this name !PHP Code:
F_email_from = new Ext.form.TextField({
plugins: [new Ext.ux.FieldReadOnlyPlugin()]
,vtype:'email'
,fieldLabel: 'Expediteur'
,anchor : '100%'
,listeners:{
valid:function(){
this.valide=true;
btn_email_go_check();
}
,invalid:function(){
this.valide=false;
btn_email_go_check();
}
}
});
F_email_to = new Ext.form.TextField({
plugins: [new Ext.ux.FieldReadOnlyPlugin()]
,vtype:'email'
,fieldLabel: 'Destinataire(s)'
,anchor : '100%'
,listeners:{
valid:function(){
this.valide=true;
btn_email_go_check();
}
,invalid:function(){
this.valide=false;
btn_email_go_check();
}
}
});

Then, with btn_email_go_check wait for readyBox:
Maybe not the better way, but it works for my case.PHP Code:function btn_email_go_check(){
Ext.log('Lauch Test');
if(Fly_Email.boxReady){
if(F_email_from.valide && F_email_to.valide ){
btn_email_go.enable();
} else {
btn_email_go.disable();
}
}
}
Bye


Reply With Quote