Results 1 to 3 of 3

Thread: Extended Class: Is Not A Constructor

  1. #1

    Default Extended Class: Is Not A Constructor

    I created an extended class that when called generates an error: is not a constructor. I thought that you do not have to explicitly create a constructor function when inheriting from a base Ext class? I don't understand what is going on here... The source (extended class followed by call):

    Code:
    /*********************************
    Start: application.ux.bugreport.js
    *********************************/
    Application.UX.BugReport = Ext.extend(Ext.Window,
        {
            initComponent:function() {
                Ext.apply(this, {
                        items: [
                            {
                                xtype: 'window'
                                ,title: 'Report A Bug'
                                ,modal: true
                                ,width: 600
                                ,resizable: true
                                ,layout: 'fit'
                                ,items: [
                                    {
                                        xtype: 'form'
                                        ,layout: 'card'
                                        ,deferredRender: true
                                        ,activeItem: 0
                                        ,bbar: [
                                            '->'
                                            ,{
                                                id: 'back'
                                                ,text: '<< Previous'
                                            }
                                            ,{
                                                id: 'next'
                                                ,text: 'Next >>'
                                            }
                                            ,{
                                                id: 'cancel'
                                                ,text: 'Cancel'
                                            }
                                        ]
                                        ,items: [
                                            vbugreport_1
                                            ,vbugreport_2
                                            ,vbugreport_3
                                            ,vbugreport_4
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                )
                Application.UX.BugReport.superclass.initComponent.apply(this, arguments);
            } // eo initComponent
        }); // eo Application.UX.BugReport
     
    Ext.reg('bugreport', Application.UX.BugReport);
     
    /*********************************
    End:application.ux.bugreport.js
    *********************************/
     
    /*********************************
    Start: The Call
    *********************************/
    var vBugReport = new Application.UX.BugReport(); // blows-up here as 'is not a constructor'
    vBugReport.show();

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

    Default

    Runs fine if:

    a) I declare Application.UX

    Code:
    Ext.ns('Application.UX');
    b) I put the call code in an onReady block.

    Why one would want to nest a window inside a window is a bit beyond me... however.

    Code:
    Ext.ns('Application.UX');
    /*********************************
     Start: application.ux.bugreport.js
     *********************************/
    Application.UX.BugReport = Ext.extend(Ext.Window, {
        initComponent: function(){
            Ext.apply(this, {
                items: [{
                    xtype: 'window',
                    title: 'Report A Bug',
                    modal: true,
                    width: 600,
                    resizable: true,
                    layout: 'fit',
                    items: [{
                        xtype: 'form',
                        layout: 'card',
                        deferredRender: true,
                        activeItem: 0,
                        bbar: ['->', {
                            id: 'back',
                            text: '<< Previous'
                        }, {
                            id: 'next',
                            text: 'Next >>'
                        }, {
                            id: 'cancel',
                            text: 'Cancel'
                        }],
                        items: []
                    }]
                }]
            })
            Application.UX.BugReport.superclass.initComponent.apply(this, arguments);
        } // eo initComponent
    }); // eo Application.UX.BugReport
    
    Ext.reg('bugreport', Application.UX.BugReport);
    
    /*********************************
     End:application.ux.bugreport.js
     *********************************/
    
    /*********************************
     Start: The Call
     *********************************/
    Ext.onReady(function(){
        var vBugReport = new Application.UX.BugReport(); // blows-up here as 'is not a constructor'
        vBugReport.show();
    });
    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

    Point taken about a window within a window - I completely forgot to update the extended class. My bad - I removed the outer Window. However, I also have Ext.ns('Application.UX') in my Page.init but when I inspect Application.UX.BugReport it is "undefined" and FBug reports "...is not a constructor." Application.UX resolves to "object." Thanks for any assistance you can provide.

    Quote Originally Posted by evant View Post
    Runs fine if:

    a) I declare Application.UX

    Code:
    Ext.ns('Application.UX');
    b) I put the call code in an onReady block.

    Why one would want to nest a window inside a window is a bit beyond me... however.

    Code:
    Ext.ns('Application.UX');
    /*********************************
     Start: application.ux.bugreport.js
     *********************************/
    Application.UX.BugReport = Ext.extend(Ext.Window, {
        initComponent: function(){
            Ext.apply(this, {
                items: [{
                    xtype: 'window',
                    title: 'Report A Bug',
                    modal: true,
                    width: 600,
                    resizable: true,
                    layout: 'fit',
                    items: [{
                        xtype: 'form',
                        layout: 'card',
                        deferredRender: true,
                        activeItem: 0,
                        bbar: ['->', {
                            id: 'back',
                            text: '<< Previous'
                        }, {
                            id: 'next',
                            text: 'Next >>'
                        }, {
                            id: 'cancel',
                            text: 'Cancel'
                        }],
                        items: []
                    }]
                }]
            })
            Application.UX.BugReport.superclass.initComponent.apply(this, arguments);
        } // eo initComponent
    }); // eo Application.UX.BugReport
    
    Ext.reg('bugreport', Application.UX.BugReport);
    
    /*********************************
     End:application.ux.bugreport.js
     *********************************/
    
    /*********************************
     Start: The Call
     *********************************/
    Ext.onReady(function(){
        var vBugReport = new Application.UX.BugReport(); // blows-up here as 'is not a constructor'
        vBugReport.show();
    });

Posting Permissions

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