I put together a small-sized application, and I'm factoring to reduce the total number of lines supported, as well as performance tuning. The use case in which I asked this question is that I have a button built into the menu that calls (or requires a call) a method on the controller that displays the form. Currently, this is done by directly linking to a specific button control, creating a panel, and placing that panel inside my viewport.
Question: ExtJS 4.1 Call One Controller From Another begins to solve the problem of best practices at the end of the answers, but the base register, which can be reproduced or expanded to cover more complex implementations, is not consistent (which is the purpose of my question).
Given two controllers:
Controller "main menu".
Ext.define("App.controller.Menu", {
extend: "Ext.app.Controller",
init: function () {
this.control({
"viewport > mainmenu > button": function (ctl, evt) {
}
});
}
});
User account controller
Ext.define("App.controller.User", {
extend: "Ext.app.Controller",
stores: ["User"],
views: ["user.Edit", "user.List"],
init: function () {
}
});
Question
What will be the (best) way to implement a crosswise connection between the two controllers in order to properly delegate responsibility for responding to the event of clicking on the menu button for "Create a new account?"
One possible solution
Using the component request, I can easily narrow the focus of the button in the main menu using the tag property so that the user controller responds directly to the event:
"viewport > mainmenu > button [tag=user.create]": function () {}
, .
// controller/Menu.js
// switch on tag case "user.create"
App.controller.User.createUserForm()
, , , " " . , , "" , , , . , ; , , ( .) , , , .
!