3.2.0

How to set properities for all new Inputs ?

Hi, another dumb question...

I've tryed this:

AW.UI.INPUT.onControlActivated = function(event){
   this.setStyle('background', '#CFDEFF'); 
}
        
AW.UI.INPUT.onControlDeactivated = function(event){  
   this.setStyle('background', 'white');
}


but it seems to not work. I just do not want to make it for each and every input itself...

What am I doing wrong ?
ASJ
April 23,
You are adding methods to the constructor function. Instead you should modify the object prototype -

AW.UI.Input.prototype.onControlActivated = function(event){
   this.setStyle('background', '#CFDEFF');
}

AW.UI.Input.prototype.onControlDeactivated = function(event){
   this.setStyle('background', 'white');
}

var obj = new AW.UI.Input;
document.write(obj);


Even better would be adding your subclass -

var MyInput = AW.UI.Input.subclass();

MyInput.create = function(){

    var obj = this.prototype;

    obj.onControlActivated = function(event){
       this.setStyle('background', '#CFDEFF');
    }

    obj.onControlDeactivated = function(event){
       this.setStyle('background', 'white');
    }
}

var obj = new MyInput;
document.write(obj);
Alex (ActiveWidgets)
April 24,

This topic is archived.

See also:


Back to support forum