1. #21
    Ext Premium Member yyogev's Avatar
    Join Date
    Jun 2009
    Location
    Shoham, Israel
    Posts
    196
    Vote Rating
    6
    yyogev is on a distinguished road

      0  

    Exclamation Fix IE error when using ExtJS 3.0.3

    Fix IE error when using ExtJS 3.0.3


    First of all, thanks for this useful code.

    I am using ExtJS 3.0.3, and users reported they had problem using my ExtJS-based UI with IE 8.

    I found out that the onRender call was changed so now it takes two arguments, therefore the onRender function needs to be modified as follows:
    Code:
        onRender : function (ct, position) {
            Ext.form.TextFieldRemoteVal.superclass.onRender.call(this, ct, position);
    Yaron Yogev

    IT Software Developer

  2. #22
    Sencha User wemerson.januario's Avatar
    Join Date
    Nov 2008
    Location
    Brazil, Goias, Goiânia
    Posts
    442
    Vote Rating
    7
    wemerson.januario will become famous soon enough

      0  

    Default nice

    nice


    nice work

  3. #23
    Sencha User
    Join Date
    Feb 2010
    Location
    Brescia
    Posts
    60
    Vote Rating
    0
    ladro1987 is on a distinguished road

      0  

    Default


    Hi,
    I have this problem in error's console:

    f.isValid is not a function

    This is the textField:
    Code:
    var prova = new Ext.form.TextFieldRemoteVal({
            // New possibility
        remoteValidation: 'onBlur',         // When start remote validation, value: 'onBlur' or 'onValidate'
        urlRemoteVal: 'dynamic/prova.php',                     // Url for remote validation
        method: 'POST',                         // Optional, method for remote validation 'GET' or 'POST', default POST
        paramsRemoteVal: { w: 'testPseudo' },     // Optional, additional parameter(s) (Object or String)
        timeout: 30,                             // Optional, timeout for validation request, default 30
        badServerRespText: 'Impossibile trovare la pagina',             // Optional, text showing after bad server response, default: 'Error: bad server response during validation'
        badComText: 'My text'                     // Optional, text showing after incorrect comunication, default: 'Error: validation unavailable'
    });
    and this is the php code (prova.php)
    PHP Code:
    <?php

    if (!$_POST)
        echo(
    '{ success: "true" } ');
    else
        echo(
    '{success: "false", errors: { reason: "Error" }} ');
    ?>
    I fix the code, adding the following code into the ext-all-debug.js

    Code:
    Ext.form.TextFieldRemoteVal = function(config){
        Ext.form.TextFieldRemoteVal.superclass.constructor.call(this, config);
    	if( this.urlRemoteVal ) {
    		if( this.remoteValidation == 'onValidate' ) {
    			this.on('valid', this.startRemoteVal.createDelegate(this));
    		}else if( this.remoteValidation == 'onBlur' ) {
    			this.on('blur', this.startRemoteVal.createDelegate(this));
    		}
    	}
    };
    
    Ext.extend(Ext.form.TextFieldRemoteVal, Ext.form.TextField, {
    	remoteValidation: null, /* 'onValidate' or 'onBlur' */
    	urlRemoteVal: null,
    	timeout: 30,	
    	method: 'POST',
    	badServerRespText: 'Error: bad server response during validation',
    	badComText: 'Error: validation unavailable',
    	
    	// redefinition 
    	onRender : function(ct){
    		Ext.form.TextFieldRemoteVal.superclass.onRender.call(this, ct);
    		
    		this.remoteCheckIcon = ct.createChild({tav:'div', cls:'x-form-remote-wait'});
    		this.remoteCheckIcon.hide();
    	},
    	
    	// private
    	alignRemoteCheckIcon : function(){
            this.remoteCheckIcon.alignTo(this.el, 'tl-tr', [2, 2]);
        },
    	
    	// private
    	getParams: function() {
            var tfp = (this.name||this.id)+'='+this.getValue();
            var p = (this.paramsRemoteVal?this.paramsRemoteVal:'');
            if(p){
                if(typeof p == "object")
                    tfp += '&' + Ext.urlEncode(p);
                else if(typeof p == 'string' && p.length)
                    tfp += '&' + p;
            }
    		return tfp;
    	},
    	
    	// public
    	startRemoteVal: function() {
    		var v = this.getValue();
    		// don't start a remote validation if the value doesn't change (getFocus/lostFocus for example)
    		if( this.lastValue != v ) {
    			this.lastValue = v;
    			if( this.transaction ) {
    				this.abort();
    			}
    			this.alignRemoteCheckIcon();
    			this.remoteCheckIcon.show();
    			var params = this.getParams();
    			this.transaction = Ext.lib.Ajax.request(
    					            this.method,
    					            this.urlRemoteVal + (this.method=='GET' ? '?' + params : ''),
    					            {success: this.successRemoteVal, failure: this.failureRemoteVal, scope: this, timeout: (this.timeout*1000)},
    					            params);
    		}
    		// but if remote validation error, show it! (because validateValue reset it)
    		else if( !this.isValid ) {
    			this.markInvalid(this.currentErrorTxt);
    		}
    	},
    	
    	// public
    	abort : function(){
    		if(this.transaction){
    			Ext.lib.Ajax.abort(this.transaction);
    		}
    	},
    	
    	// private
    	successRemoteVal: function(response) {
    		this.transaction = null;
    		this.remoteCheckIcon.hide();
    		var result = this.processResponse(response);
    		if(result) {
    			if(result.errors) {
    				this.currentErrorTxt = result.errors;
    				this.markInvalid(this.currentErrorTxt);
    				this.isValid = false;
    			} else {
    				this.isValid = true;
    			}
    		}else{
    			this.currentErrorTxt = this.badServerRespText;
    			this.markInvalid(this.currentErrorTxt);
    			this.isValid = false;
    		}
    	},
    	
    	// private
    	failureRemoteVal: function(response) {
    		this.transaction = null;
    		this.remoteCheckIcon.hide();
    		this.currentErrorTxt = this.badComText;
    		this.markInvalid(this.currentErrorTxt);
    		this.isValid = false;
    	},
    	
    	// private
    	processResponse: function(response) {
            return (!response.responseText ? false : Ext.decode(response.responseText));
        }
    
    });
    Can ayone help me please?? :-)

    Roberto.

  4. #24
    Sencha User
    Join Date
    Jan 2008
    Posts
    64
    Vote Rating
    0
    ZeusTheTrueGod is on a distinguished road

      0  

    Default This approach is silly

    This approach is silly


    Hi all, I dislike the idea of having a special class for this purpose.
    Server-side validation is a feature. You can have 10 features - autosize,validation, auto enable/disable and so on.

    The only correct approach is using a plugin. The plugin should subribe on some events - blur or keyup or something else and make an ajax request.

    Else I would like to create a class Ext.ux.FormTextFieldWithRemoveValAndAutoSizingAndEnablingItemsAndSimulatingFormPreviewAndLocalizationAndOneMoreCoolFeature

  5. #25
    Ext Premium Member yyogev's Avatar
    Join Date
    Jun 2009
    Location
    Shoham, Israel
    Posts
    196
    Vote Rating
    6
    yyogev is on a distinguished road

      0  

    Default


    Quote Originally Posted by ZeusTheTrueGod View Post
    Hi all, I dislike the idea of having a special class for this purpose.
    Server-side validation is a feature. You can have 10 features - autosize,validation, auto enable/disable and so on.

    The only correct approach is using a plugin. The plugin should subribe on some events - blur or keyup or something else and make an ajax request.

    Else I would like to create a class Ext.ux.FormTextFieldWithRemoveValAndAutoSizingAndEnablingItemsAndSimulatingFormPreviewAndLocalizationAndOneMoreCoolFeature
    There is already such a plug-in, which I've been using successfully: the remoteValidator plug-in by Saki
    http://www.extjs.com/learn/Plugin:RemoteValidator
    Yaron Yogev

    IT Software Developer

  6. #26
    Sencha User
    Join Date
    Sep 2012
    Posts
    1
    Vote Rating
    0
    mrgamer is on a distinguished road

      0  

    Default


    Personally i'm new to ExtJS, i wanted to realize a remote validation system for a simple TextField... [edit: using 3.4.0]

    I tried either with Vtype and with { validation: function (value){ .... "£$"!$="! ...} } when declaring the TextField, none of them work, the Ajax request works like a charm, but the Ext.Ajax.Request return value doesn't work

    It's cause Ext.Ajax it's a singleton?

    PS: i can post the code, but it's kind of useless, it's just a simple textfield that does an AJAX request, evaluates the response and on answer returns true/false.