title: Binding events for more than a single controller in ExtJs
body: <p>I've assembled a modestly sized application and I am in the process of factoring code to reduce the overall number of maintained lines, as well as performance tuning. The use case that has me posting this question is that I have a button embedded in a menu that invokes (or needs to invoke) a method on a controller that displays a form. This currently is implemented using a direct reference to the specific button control, creating a panel, and putting that panel inside of my viewport.</p>
  <p>The question at: <a href="https://stackoverflow.com/questions/12065926/extjs-4-1-call-one-controller-from-another">ExtJS 4.1 Call One Controller From Another</a> begins to address the issue of best-practices near the end of responses, but doesn't really settle on a base-case that can be reproduced or extended to cover more complex implementations (which is the aim of my question.)</p>
  <p>Given the two controllers:</p>
  <h3>A &quot;main menu&quot; controller.</h3>
  <pre><code>// controller/Menu.js
  Ext.define(&quot;App.controller.Menu&quot;, {
      extend: &quot;Ext.app.Controller&quot;,
      init: function () {
          this.control({
              &quot;viewport &gt; mainmenu &gt; button&quot;: function (ctl, evt) {
              }
          });
      }
  });
  </code></pre>
  <h3>A user account controller</h3>
  <pre><code>// controller/User.js
  Ext.define(&quot;App.controller.User&quot;, {
      extend: &quot;Ext.app.Controller&quot;,
      stores: [&quot;User&quot;],
      views: [&quot;user.Edit&quot;, &quot;user.List&quot;],
      init: function () {
      }
  });
  </code></pre>
  <h3>The Question</h3>
  <p>What would be the (best) way to implement a crosswise connection between the two controllers to properly delegate the responsibility of responding to a click event on the menu button for &quot;Create a New Account?&quot;</p>
  <h3>One Possible Solution</h3>
  <p>Using componentquery I can <em>easily</em> narrow down the focus of the button in the main menu view using a tag property such that the User controller is responding directly to the event:</p>
  <pre><code>// controller/User.js
  &quot;viewport &gt; mainmenu &gt; button [tag=user.create]&quot;: function () {}
  </code></pre>
  <h3>An unknown alternative</h3>
  <p>Or I could possible winnow my way through the object graph to find the reference to the User controller from the Menu controller and invoke it that way.</p>
  <pre><code>// controller/Menu.js
  // switch on tag case &quot;user.create&quot;
  App.controller.User.createUserForm()
  </code></pre>
  <h3>The real question</h3>
  <p>The question that results from all of this is what the &quot;most acceptable&quot; solution is here. One could imagine the use of a third, mediating controller, to &quot;route&quot; requests from controls to controllers but I think that goes against what the remainder of the framework is attempting to do. Using a variation of either of these methods currently works however neither feels completely clean and reliable; or ultimately maintainable long-term (as code gets spread out rather quickly.) Additionally the thought had occurred to us to drop into raw events but we run into the same kind of maintainability issues there.</p>