Results 1 to 5 of 5

Thread: how to create an instance of an Ext.extend

  1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    60

    Default how to create an instance of an Ext.extend

    I have done the following:

    App.NumberField = Ext.extend(App.ux.NumberField, {
    initComponent:function() {
    ...
    }
    });
    Ext.reg('app.numberfield', App.NumberField);

    But how do I create an instance now?

    var test = new app.numberfield({...});

    don't function :-(

  2. #2
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750

    Default

    Code:
     
    var test = new App.NumberField(...);
    Ext.reg is for registering a subclassed component type for lazy instantation. See: http://dev.sencha.com/deploy/dev/doc...t&member=xtype

  3. #3
    Sencha User
    Join Date
    Aug 2010
    Posts
    60

    Default

    The problem is that I am getting with your code

    App.NumberField is not a constructor

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    Code:
    Ext.ns("App");
    App.NumberField = Ext.extend(Ext.form.NumberField, {
        ....
    });
    Ext.reg("app.numberfield", App.NumberField);
    Code:
    var field = new App.NumberField({ .... });
    or
    Code:
    var field = {
        xtype: "app.numberfield",
        ....
    };
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  5. #5
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,791

    Default

    Is your class defined in a separate JS file? Have you remembered to include that file in your HTML?

Similar Threads

  1. Best Practice Question - When to create a new class vs an instance?
    By caseyb in forum Ext 3.x: Help & Discussion
    Replies: 5
    Last Post: 6 Oct 2010, 8:52 AM
  2. Create a singleton, or retrieve an instance ?
    By gu1gui in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 8 Mar 2010, 1:10 AM
  3. Replies: 6
    Last Post: 11 Jun 2009, 9:28 PM
  4. Trying to extend Ext.form.Field to create SliderField
    By dmauer in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 3 Apr 2008, 10:17 AM
  5. possibly a stupid question: create an "instance" of a tab/panel/window ?
    By PromaneX in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 28 Mar 2008, 9:37 AM

Posting Permissions

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