Missing Component and Container findCt bubble methods

January 8th, 2009
  • I believe the effect of the following should be included into the next Ext JS build.


    Ext.apply(Ext.Container.prototype,{

    findCtById : function(id){
    var m, ct = this;
    this.bubble(function(c){
    if(ct != c && c.id === id){
    m = c;
    return false;
    }
    });
    return m null;
    },

    findCtByType : function(xtype){
    return typeof xtype == 'function' ?
    this.findCtBy(function(c){
    return c.constructor === xtype;
    }) :
    this.findCtBy(function(c){
    return c.constructor.xtype === xtype;
    });
    },

    findCt : function(prop, value){
    return this.findByCt(function(c){
    return c[prop] === value;
    });
    },

    findCtBy : function(fn, scope){
    var m = , ct = this;
    this.bubble(function(c){
    if(ct != c && fn.call(scope c, c, ct) === true){
    m.push(c);
    }
    });
    return m;
    }

    });


    Ext.apply(Ext.Component.prototype,{

    bubble : function(fn, scope, args){
    var p = this;
    while(p){
    if(fn.apply(scope p, args [p]) === false){
    break;
    }
    p = p.ownerCt;
    }
    },

    findCtById : function(id){
    var m, ct = this;
    this.bubble(function(c){
    if(ct != c && c.id === id){
    m = c;
    return false;
    }
    });
    return m null;
    },

    findCtByType : function(xtype){
    return typeof xtype == 'function' ?
    this.findCtBy(function(c){
    return c.constructor === xtype;
    }) :
    this.findCtBy(function(c){
    return c.constructor.xtype === xtype;
    });
    },

    findCt : function(prop, value){
    return this.findByCt(function(c){
    return c[prop] === value;
    });
    },

    findCtBy : function(fn, scope){
    var m = , ct = this;
    this.bubble(function(c){
    if(ct != c && fn.call(scope c, c, ct) === true){
    m.push(c);
    }
    });
    return m;
    }

    });


  • And I still think something like this is a good idea.


  • I don't know how you can memorize every posting, but whatever voodoo that you do it is good for us.

    Thanks,
    Jerry


  • Great minds think alike Jerry!

    http://extjs.com/forum/showthread.php?p=118908#post118908

    But remember a Container isa Component. Check the inheritance.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Missing Component and Container findCt bubble methods , Please add it free.