Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha Premium Member
    Join Date
    Jan 2009
    Posts
    339
    Vote Rating
    110
    firefoxSafari is a glorious beacon of light firefoxSafari is a glorious beacon of light firefoxSafari is a glorious beacon of light firefoxSafari is a glorious beacon of light firefoxSafari is a glorious beacon of light firefoxSafari is a glorious beacon of light

      1  

    Default [CLOSED]Override doesn't work with singletons

    [CLOSED]Override doesn't work with singletons


    I'm not 100% sure if this is a bug or intended behavior, but I found it really annoying so I'm posting it.

    If you define a class as a singleton, then the override method on the class is not present. For example, this fails with an error

    Code:
    Ext.define('Ext.ux.TestClass', { singleton: true }); Ext.ux.TestClass.override({ testMethod: function() { alert('hi'); } });
    Also, Ext.override will just silently fail.

    Code:
      Ext.override(Ext.ux.TestClass, {
       testMethod: function() {
        alert('hi');
       } 
      });
    Now I realize this will work after the class is defined.

    Code:
      Ext.ux.TestClass.testMethod = function() {
       alert('hi');
      };
    However, it would be nice to have a unified model for overriding and I can see this tripping a lot of people up, especially if they try to override internal ext classes to work around problems. I ran into it trying to alter TableChunker to let me select text in a grid.

    Is this a bug or intended behavior?

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,546
    Vote Rating
    64
    Animal is a jewel in the rough Animal is a jewel in the rough Animal is a jewel in the rough

      0  

    Default


    Override sets properties in a class's prototype

    A singleton is just an object with properties.

  3. #3
    Sencha Premium Member
    Join Date
    Jan 2009
    Posts
    339
    Vote Rating
    110
    firefoxSafari is a glorious beacon of light firefoxSafari is a glorious beacon of light firefoxSafari is a glorious beacon of light firefoxSafari is a glorious beacon of light firefoxSafari is a glorious beacon of light firefoxSafari is a glorious beacon of light

      0  

    Default


    Thanks for the info - I'll assume this is expected behavior, then.

    I understand how it's working now - setting the object property rather than touching the prototype was what my last snippet did. However, it seemed to me with the new Ext.define syntax you tried to present a unified way to create the definition for classes, both instantiable and ones intended to be singletons. Creating one intended to be singleton just requires a different config attribute. Given this, it seemed counterintuitive to me that the override mechanism wasn't smart enough to figure out what I meant when I tried to override a method on a singleton - it seemed there was a disconnect between define and override.

    This tripped me up because just looking at TableChunker it looked like a regular class. Not a huge deal either way; we'll just have to condition ourselves to look for the singleton config option.

  4. #4
    Sencha User VDP's Avatar
    Join Date
    Feb 2012
    Location
    Boom, Belgium
    Posts
    87
    Vote Rating
    10
    VDP will become famous soon enough

      1  

    Default


    It would be nice if I could override properties on a singleton too.

    Then I can use the default sencha way of requiring an override. Now I do an empty override (doing nothing but not tripping any warnings). And just merge the properties..

    In a file: TestClass

    Code:
    Ext.define('TestClass', {    singleton: true});
    In a file: overrides/TestClass
    Code:
    Ext.define('Ext.overrides.TestClass', {
        override: 'TestClass'
    });
    Ext.merge(TestClass, {
        propA: 'valA',
        probB: function(){ console.log('Bam!'); }
    });

Similar Threads

  1. [CLOSED] Div in Window, doesn't work with 3.2
    By cnicolas in forum Ext 3.x: Bugs
    Replies: 2
    Last Post: 12 Sep 2010, 3:55 AM
  2. [CLOSED][3.0.0] ComboBox select doesn't work in IE6
    By iryndin in forum Ext 3.x: Bugs
    Replies: 3
    Last Post: 2 Dec 2009, 5:30 AM
  3. Override an extended extension doesn't work
    By Dr. Flink in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 16 Oct 2008, 5:24 AM
  4. Replies: 3
    Last Post: 30 Mar 2008, 2:30 PM

Thread Participants: 2