Results 1 to 2 of 2

Thread: Why is the event handler not found in the child panel view controller?

  1. #1
    Sencha Premium Member
    Join Date
    Jan 2010
    Location
    Vancouver, Canada
    Posts
    261
    Answers
    4

    Default Why is the event handler not found in the child panel view controller?

    What I am trying to do: I have a parent panel and a child panel (each with its own view controller) and I want the child panel to handle a custom event that I fire from the parent panel. The function that handles the custom event is defined in the child panel view controller. I am using Sencha Architect to build the UI (this is important). When I try to add the listeners property in SA, it wraps with a config:

    Code:
    config: {
      listeners: {
        myEvent: 'onMyEventX'
      }
    }
    In SA I also have the option to use a feature called processConfig. It creates this code:
    Code:
      initConfig: function(instanceConfig) {
        var me = this,
          config = {};
        me.processSelfPayDependentChangesDependentChangeEditPanel(config);
        if (instanceConfig) {
          me.self.getConfigurator().merge(me, config, instanceConfig);
        }
        return me.callParent([config]);
      },
    
    
      processSelfPayDependentChangesDependentChangeEditPanel: function(config) {
        // set the listeners (I added the following lines)
        config.listeners = {
          myEvent: 'onMyEventX',
        };
      }
    I created a fiddle to reproduce this issue: https://fiddle.sencha.com/#view/editor&fiddle/2rrq.
    If you run the fiddle and click the Ok button you get the following error: No method named "onMyEvent" on ParentPanelController.
    If you remove the config wrapper, it works fine.

    My question is why is it not finding the method in the child panel view controller when config wraps the listeners declaration in the child panel or when initConfig is overriden?

    Here is the doc for config: https://docs.sencha.com/extjs/6.6.0/...tml#cfg-config.

    Thanks

  2. #2
    Sencha Premium Member
    Join Date
    Jan 2010
    Location
    Vancouver, Canada
    Posts
    261
    Answers
    4

    Default

    OK, I found a fix in SA. In SA I selected the panel, I expanded the View Controller Event Bindings and I entered the event name in the text field instead of selecting an existing one from the list. SA accepts it and it creates the listeners property without wrapping it in a config. Then it all works as it is supposed to.

Posting Permissions

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