Results 1 to 6 of 6

Thread: Dynamic Extend?

  1. #1

    Default Dynamic Extend?

    Hi, i'm trying to extend my classes dynamic.
    But i got error "TypeError: Can't get property constructor from undefined value"

    What i've:

    Code:
    function compileFunc(fsource){
    	var Func = Ext.extend(Ext.util.Observable,fsource);
    	return Func;
    }
    and this is how i call function

    Code:
    new (compileFunc(mods[0].source))()
    this is source of some module

    Code:
    {
            constructor: function(config) {
                // Your preprocessing here
            	Func.superclass.constructor.apply(this, arguments);
                // Your postprocessing here
            },
    
            yourMethod: function() {
                // etc.
            }
        }


    whats wrong? or i can't extend class from some variable?

  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    19,256

    Default

    You should be able to, try this:

    Code:
    var o = 
    {
       foo: function()
       {
          return 'hi!';
       }
    };
    
    var MyClass = Ext.extend(Object, o);
    var c = new MyClass();
    alert(c.foo());
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3

    Default

    in my case - var o is a string... i get module source from Ajax request

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    Well you have to eval it then. You can't extend a string, you extend a function.

  5. #5

    Default

    Well you have to eval it then
    this is my main problem - i use Adobe AIR...
    well, thx ... will try to find some solution...

  6. #6
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,892

    Default

    There must be a way to eval in Air, otherwise, you could not recieve JSON.

Posting Permissions

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