1. #1
    Sencha User
    Join Date
    Mar 2009
    Posts
    14
    Vote Rating
    0
    jpongin is on a distinguished road

      0  

    Default Sencha Touch Inheritance Question

    Sencha Touch Inheritance Question


    Hi. We are currently building out a product prototype using Sencha Toucha and ExtJS 4.

    I was under the assumption that Sencha Touch 1.1 and ExtJS 4 were going to use the same inheritance syntax as they both share the same core code. However, this doesn't seem to be the case. Sencha Touch 1.1's inheritance syntax uses ExtJS 3.x's Ext.extend(...) and not ExtJS4's Ext.define(...).

    Sencha Touch Inheritance Syntax (much like ExtJS 3.x)
    Code:
    myPanel = Ext.extend(Ext.Panel, {...});
    Ext.reg('myPanel', myPanel);
    ExtJS4 Inheritance Syntax
    Code:
    Ext.define('MyPanel', {extend: 'Panel',...});
    ExtJS 4's Ext.define(...) design is much more intuitive and elegant for defining classes and sub classes, and we would much rather use this method upfront vs. having to change our code later on.

    Does Sencha Touch plan on using Ext.define(...) to define classes in the near future?
    If so when?
    If not, why not?

  2. #2
    Sencha User
    Join Date
    Mar 2009
    Posts
    14
    Vote Rating
    0
    jpongin is on a distinguished road

      0  

    Default


    Excuse my bumping, but I'd like some type of answer or opinion from anyone with the same concern.

  3. #3
    Premium Support User
    Join Date
    Jan 2011
    Location
    Portland, Oregon
    Posts
    32
    Vote Rating
    0
    dgmelvin is on a distinguished road

      0  

    Default


    Is there an answer to this?

  4. #4
    Sencha User
    Join Date
    Jul 2011
    Location
    Minneapolis, MN
    Posts
    3
    Vote Rating
    0
    briankuyath is on a distinguished road

      0  

    Default Also interested...

    Also interested...


    [bump]

    We're also interested and would appreciate a response.

  5. #5
    Premium Support User
    Join Date
    Jan 2011
    Location
    Portland, Oregon
    Posts
    32
    Vote Rating
    0
    dgmelvin is on a distinguished road

      0  

    Default Some info

    Some info


    I asked a contact I have access to at sencha about this and he indicated it should be resolved in Sencha Touch 2 coming out this fall some time. But, I don't really have anything definitive I can point to that promises that. I sure hope they fix it. It's a really big deal for me and I imagine many others trying to share come code between mobile and desktop code.

  6. #6
    Sencha User
    Join Date
    Jul 2011
    Location
    Minneapolis, MN
    Posts
    3
    Vote Rating
    0
    briankuyath is on a distinguished road

      0  

    Default


    Quote Originally Posted by dgmelvin View Post
    I asked a contact I have access to at sencha about this and he indicated it should be resolved in Sencha Touch 2 coming out this fall some time. But, I don't really have anything definitive I can point to that promises that. I sure hope they fix it. It's a really big deal for me and I imagine many others trying to share come code between mobile and desktop code.
    @dgmelvin Does this mean that inheritance is or isn't supported in the current version of Sencha Touch? I just dove in yesterday (starting a new project) and am running into problems figuring out the syntax of all things.

  7. #7
    Premium Support User
    Join Date
    Jan 2011
    Location
    Portland, Oregon
    Posts
    32
    Vote Rating
    0
    dgmelvin is on a distinguished road

      0  

    Default


    My understanding is that touch 1 uses the inheritance model from EXTJS 3 (or very close to that) and does not support ext.define that is part of EXTJS 4 until version 2. That is what I asked about.

    It would be really nice if someone from sencha would chime in and provide an actual answer to this.

  8. #8
    Sencha User
    Join Date
    Jul 2011
    Location
    Minneapolis, MN
    Posts
    3
    Vote Rating
    0
    briankuyath is on a distinguished road

      0  

    Default


    Quote Originally Posted by dgmelvin View Post
    My understanding is that touch 1 uses the inheritance model from EXTJS 3 (or very close to that) and does not support ext.define that is part of EXTJS 4 until version 2. That is what I asked about.
    That's what I thought. Have you been able to get inheritance to work using the EXTJS 3 inheritance model? I've been looking at the API and can't seem to get my sub-class to inherit properly from its parent. Every time I call ...
    Code:
    Ext.reg('myBaseClass', myBaseClass);
    ... I get an error that says 'myBaseClass' is undefined. Yet, I've defined the class above it.

  9. #9
    Sencha User
    Join Date
    Aug 2010
    Posts
    3
    Vote Rating
    0
    rmlee is on a distinguished road

      0  

    Default Workaround for define method and alias registration

    Workaround for define method and alias registration


    You can override the Ext.define method and work with the extend and reg method to accomplish this. Simply put the following code in before any defines:

    Ext.define = Ext.define ? Ext.define :
    function(name, config) {
    var extendObj = {};
    Ext.each(config.extend.split(/\./), function(item, index) {
    extendObj = index === 0 ? window[item] : extendObj[item];
    });


    var newObj = {};
    Ext.each(name.split(/\./), function(item, index){
    newObj = index === 0 ? window[item] = {} : newObj[item] = {};
    });
    newObj = Ext.extend(extendObj, config);

    var alias = config.alias;
    if(alias) {
    Ext.reg(alias.replace(/^(widget\.)/,''), newObj);
    }
    }

    Then calling with:

    (function() {
    Ext.define('MySettings', {
    extend: 'Ext.Panel',
    alias: 'widget.mysettings',
    html: 'Settings Panel'
    });
    })();

    will be the equivalent of:

    MySettings = Ext.extend(Ext.Panel,{
    extend: 'Ext.Panel',
    alias: 'widget.mysettings',
    html: 'Settings Panel'
    });
    Ext.reg('mysettings', MySettings);

    This provides a consistent behavior for extending an object using Ext.define. Not it is not handling a case with no extension. However, that should be pretty straight forward in that you would simply check for extension and if it doesn't exist don't call the extend method. Have not worked this out yet.

  10. #10
    Sencha User
    Join Date
    Aug 2010
    Posts
    3
    Vote Rating
    0
    rmlee is on a distinguished road

      0  

    Default Update for workaround to handle not extending a base class

    Update for workaround to handle not extending a base class


    Ext.define = Ext.define ? Ext.define :
    function(name, config) {
    var newObj;
    Ext.each(name.split(/\./), function(item, index){
    newObj = index === 0 ? window[item] = {} : newObj[item] = {};
    });


    var extendName = config.extend;
    var extendObj;
    if(extendName) {
    Ext.each(config.extend.split(/\./), function(item, index) {
    extendObj = index === 0 ? window[item] : extendObj[item];
    });
    newObj = Ext.extend(extendObj, config);
    }


    var alias = config.alias;
    if(alias) {
    Ext.reg(alias.replace(/^(widget\.)/,''), newObj);
    }
    }

Similar Threads

  1. Replies: 10
    Last Post: 20 Jan 2012, 10:10 AM
  2. Newbie Question on Sencha touch framework
    By mAuo in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 2 Feb 2011, 11:31 AM
  3. Newbie Question to start Sencha Touch
    By sideeque in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 3 Dec 2010, 6:52 AM
  4. Sencha Touch Contest question
    By qooleot in forum Sencha Touch 1.x: App Contest
    Replies: 2
    Last Post: 12 Oct 2010, 11:32 AM
  5. Question about inheritance
    By mankz in forum Community Discussion
    Replies: 17
    Last Post: 21 Oct 2009, 7:14 AM

Thread Participants: 3

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar