1. #11
    Ext JS Premium Member
    Join Date
    Mar 2010
    Posts
    71
    Vote Rating
    2
    softwarezman is on a distinguished road

      0  

    Default


    Do you have your Ext.form.* stuff being required anywhere else? Sounds like it'd be the order that things are being executed causing it. What would happen if you put a
    Code:
    requires: 'Ext.form.field.VTypes'
    or something in there to make sure it is loaded first?

  2. #12
    Sencha User
    Join Date
    Oct 2011
    Posts
    7
    Vote Rating
    1
    TestDummy is on a distinguished road

      0  

    Default


    I have a initial solution for this (still learning Ext JS 4) and that is to create a generic singleton class and place it in an appropriately named subdirectory of app. The code is as follows:

    Ext.define('MyApp.util.Validation', {

    singleton : true,
    // Add as many as you want
    nameValidation: function() {
    Ext.form.VTypes["nameVal"] = /^[a-zA-Z][-_ '.a-zA-Z0-9]{0,50}$/;
    Ext.form.VTypes["name"] = function(v){
    return Ext.form.VTypes["nameVal"].test(v);
    };
    Ext.form.VTypes["nameText"] = "Name must begin with a letter and cannot exceed 50 characters";
    Ext.form.VTypes["nameMask"] = /[-_ .a-zA-Z0-9']/;
    },
    // Execute all the the above functions in one place
    registerVtypes: function() {
    // Call additional functions here
    this.nameValidation();
    }

    });

    Then, in app.js:

    launch: function() {
    Ext.require('MyApp.util.Validation');
    }

    And finally in the view using the custom vtypes:

    var rvt = MyApp.util.Validation.registerVtypes();

    On the field:

    vtype: 'name'

    Hopefully, someone with more OO Javascript experience will see a smarter, less clumsy way to do this.

  3. #13
    Sencha User
    Join Date
    Jul 2009
    Posts
    30
    Vote Rating
    0
    jmozley is on a distinguished road

      0  

    Default


    I used the following in Validation.js

    Code:
    Ext.define('MyApp.util.Validation', {
    
            singleton : true,
            
            // Validate a CIDR net
            cidrValidation : function() {
                Ext.form.field.VTypes.cidrVal = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d{1,2}$/;
                Ext.form.field.VTypes.cidr = function(toCheck){
                    return Ext.form.field.VTypes.cidrVal.test(toCheck);
                }
                
                Ext.form.field.VTypes.cidrText = "Must be a valid CIDR network in the form 192.168.1.0/24";
            }
            
        
        },
        
        function() {
            console.log('registered VTypes');
            this.cidrValidation();
            //add more here
        }
    
    );
    And in app.js

    Code:
        launch: function() {
            Ext.require('MyApp.util.Validation');
        },
    The meant I did not need to put a function call in each view such as:

    Code:
    var rvt = MyApp.util.Validation.registerVtypes();
    HTH someone. If there is a more "best practise" way would be nice to know.

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar