Results 1 to 2 of 2

Thread: "New" vs. Ext.Create?

  1. #1
    Sencha User
    Join Date
    Nov 2007
    Vote Rating

    Default "New" vs. Ext.Create?

    I am currently porting a 3.4 app to 4.1 and have 100's of lines of code like

    var frmId = new Ext.form.field.Text({...});

    In Ext 4.x, these calls could be converted to:

    var frmId = Ext.create('Ext.form.field.Text',{...});

    I understand maybe the benefits of using Ext.define/Ext.create for application classes but why use Ext.create for Ext classes?

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL
    Vote Rating


    Ext.create will instantiate the class just like the new keyword will except it checks to see if the class has already been loaded. If not then it will load the file. Once it has made sure the class definition exists then it will create the instance.

    If you know the class is going to be loaded, using the new keyword is fine, I do it about 99% myself.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:

Posting Permissions

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