Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1

    Join Date
    Nov 2012
    Posts
    7
    Vote Rating
    0
    mariuszk is on a distinguished road

      0  

    Default overridding Ext.form.Label seems not to work

    overridding Ext.form.Label seems not to work


    extjs 4.1.1 with firefox/chrom

    ovverridden constructor or initComponent are not called

    Code:
    Ext.override(Ext.form.Label, {    
        constructor: function(cfg) {
          console.log('i was here');
          this.callOverridden(arguments);
        },    
        initComponent: function() {
            console.log('i was here too');
            this.callOverridden(arguments);
        }    
    });

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,054
    Vote Rating
    659
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Overrides should use Ext.define:

    Code:
    Ext.define('Foo', {
        override: 'Ext.form.Label',
        constructor: function(cfg) {
            console.log('i was here');
            this.callOverridden(arguments);
        },
        initComponent: function() {
            console.log('i was here too');
            this.callOverridden(arguments);
        }
    });
    
    Ext.require('*');
    
    Ext.onReady(function() {
        new Ext.form.Label({
            renderTo: document.body
        });
    });
    Tested with the latest from source and I see both logs.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3

    Join Date
    Nov 2012
    Posts
    7
    Vote Rating
    0
    mariuszk is on a distinguished road

      0  

    Default


    Many thanks.

    But "Ext.define" create new "class" and override extend the existing. So they are not same.

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,054
    Vote Rating
    659
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    As it goes, if I run the same code (it's functionality equivalent) it works in the latest branch as well:

    Code:
    Ext.require('*');
    
    Ext.onReady(function() {
    
        Ext.override(Ext.form.Label, {
            constructor: function(cfg) {
                console.log('i was here');
                this.callOverridden(arguments);
            },
            initComponent: function() {
                console.log('i was here too');
                this.callOverridden(arguments);
            }
        });
        
        new Ext.form.Label();
    
    });
    The advantage of the define() syntax is it will work with dynamic loading.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

Thread Participants: 1

Tags for this Thread