Results 1 to 3 of 3

Thread: Subclass inherance and event listeners

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    12

    Default Subclass inherance and event listeners

    I've defined into Ext Designer a custom subclass of Panel, ClientAddPanel, that contains a form and a submit button which calls a saveClient method on click.


    At application launch, I can corrreclty see into the console the initComponent method call.

    The issue is when I try to instantiate a second time my subclass panel which is linked to a new tab, the initComponent method is not called so I'm loosing the default event handling for this subclass.

    Where did I miss the bus ?

    thanks for your support,


    Here is the code for my subclass :

    Code:
    Ext.define('MyApp.view.ClientAddPanel', {
        extend: 'MyApp.view.ui.ClientAddPanel',
        alias: 'widget.clientaddpnl',
    
    
        initComponent: function() { 
            console.log('ClientSearchPanel::initComponent: start');
            this.callParent(arguments);
            
            this.down('#savebtn').on('click', this.saveClient, this);        
            console.log('ClientSearchPanel::initComponent: done');
        },
    
    
        saveClient: function(button, event, options) {
            console.log("ClientAddPanel::saveClient: start");
    
                    // some stuff here
            console.log("ClientAddPanel::saveClient: form", form);
    
    
    });
    and the code that instantiate the second time my subclass :

    Code:
            var editctab = Ext.create('MyApp.view.ui.ClientAddPanel');

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    Interesting... Ext.create will create a new instance and that will execute initComponent even if the component isn't rendered.

    Side note, I see you are adding a listener to the save button in your class... are you using MVC? If so, should that be in the Controller?
    Mitchell Simoens @LikelyMitch

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

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User
    Join Date
    Nov 2011
    Posts
    12

    Default Solved !

    Thanks Mitchell for your answer ; I finally found it : Ext Designer generates automatically classes files when exporting the project. I assume there was a conflit between old and new files.

    I removed my app/view/ui folder and re-generate the project and it works fine now !

Posting Permissions

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