Results 1 to 3 of 3

Thread: How to override a singleton?

  1. #1
    Sencha User Dumas's Avatar
    Join Date
    Dec 2008
    Location
    Vienna, Austria
    Posts
    589
    Answers
    5
    Vote Rating
    10
      0  

    Default Answered: How to override a singleton?

    How can I cleanly extend the Ext.data.Validations singleton?


    The following code is not working, it returns a Sencha-internal error:
    Code:
    Ext.define('Bancha.data.override.Validations', {
        override: 'Ext.data.Validations',
        fileMessage: "is not a valid file",
        file: function(config, value) { ... }
    });
    //error: Object [object Object] has no method 'override'  at sencha-touch.js:6595
    Is this a bug?

    Thanks
    Roland

  2. You can do this via:

    Code:
    Ext.define('Bancha.data.override.Validations', {}, function() {
        Ext.apply(Ext.data.Validations, {
            fileMessage: "is not a valid file",
            file: function(config, value) { ... }
        });
    });

  3. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,556
    Answers
    3931
    Vote Rating
    1272
      1  

    Default

    You can do this via:

    Code:
    Ext.define('Bancha.data.override.Validations', {}, function() {
        Ext.apply(Ext.data.Validations, {
            fileMessage: "is not a valid file",
            file: function(config, value) { ... }
        });
    });
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

  4. #3
    Sencha User
    Join Date
    May 2013
    Posts
    1
    Vote Rating
    0
      0  

    Default Override doesn't work

    I am trying to override the extjs class Ext.dd.DragDropManager which is a singleton and I tried the above implementation and it doesn't work.

    My code:

    Code:
    Ext.define('Demo.override.DragDropManager', {}, function () {
          Ext.apply(Ext.dd.DragDropManager, {
               handleMouseMove: function (e) {
                  // my implementation   
                }
          });
    });
    Any suggestions?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •