1. #1
    Ext User
    Join Date
    Sep 2007
    Posts
    6
    Vote Rating
    0
    yarmy is on a distinguished road

      0  

    Default Binding a Button's disabled/enabled state to a Form's validity state

    Binding a Button's disabled/enabled state to a Form's validity state


    So I want my submit button to be enabled/disabled depending on the form's validity status. For example,
    Code:
    var registerButton = new Ext.Button({
        text: 'Register',
        handler: function() {},
        disabled: true
    });
            
    var firstnameField = new Ext.form.TextField({
        fieldLabel: 'First Name',
        name: 'firstname',
        allowBlank: false
    });
    
    firstnameField.on('change', function() {
        registerButton.setDisabled(!formPanel.form.isValid());
    });
    
    var secondnameField = new Ext.form.TextField({
        fieldLabel: 'Second Name',
        name: 'secondname',
        allowBlank: false
    });
    
    var formPanel = new Ext.FormPanel({
        region: 'center',
        title: 'Register Form',
        labelWidth: 80,
        frame: true,
        defaults: {width: 200},
        items: [firstnameField, secondnameField],
        buttons: [registerButton]				
    });
    
    new Ext.Viewport({
        layout: 'border',
        items: formPanel
    });
    It seems the button's disabled property does change, but changing the property doesn't re-render the button.

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    This functionality is already built into the Form - you don't have to code it yourself. Add formBind:true to the button config for any buttons in the form you want to manage. Then after creating the form, call form.startMonitoring(). This will check the form's validity on a timer and enable/disable the buttons. You should call form.stopMonitoring() before actually submitting so the timer doesn't continue to run.

  3. #3
    Ext User
    Join Date
    Sep 2007
    Posts
    6
    Vote Rating
    0
    yarmy is on a distinguished road

      0  

    Thumbs up Job's a good'un

    Job's a good'un


    Every day's a school day. Thanks.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..."