1. #1
    Ext User
    Join Date
    Sep 2008
    Location
    FRANCE, Rennes
    Posts
    68
    Vote Rating
    0
    stevanovich is on a distinguished road

      0  

    Question [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:

    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();
            }
        }    
      });
      }); 
    Here is the check function :

    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();
            }

    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.

    here is Firebug message:
    too much recursion
    [IMG]chrome://firebug/content/blank.gif[/IMG] if(l.fireFn.apply(l....this.obj||window, arguments) === false){
    Does isValid fire valid event ???

    I don't really understand where i'm wrong.

    Thanks !
    Last edited by stevanovich; 4 Dec 2008 at 6:12 AM. Reason: [SOLVED]

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,166
    Vote Rating
    674
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  3. #3
    Ext User
    Join Date
    Sep 2008
    Location
    FRANCE, Rennes
    Posts
    68
    Vote Rating
    0
    stevanovich is on a distinguished road

      0  

    Question 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. #4
    Ext User
    Join Date
    Sep 2008
    Location
    FRANCE, Rennes
    Posts
    68
    Vote Rating
    0
    stevanovich is on a distinguished road

      0  

    Thumbs up 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
    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();
            }
        }
      }); 
    And hope ExtJs will never use this name !

    Then, with btn_email_go_check wait for readyBox:

    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();
        }
        }

    Maybe not the better way, but it works for my case.

    Bye

Thread Participants: 1