I have a tabbed interface (I use the tabbed interface controller example provided)
On each of my tabs I have charts though. I would like that when the tabs shows up, the charts render at the same time.
I am guessing that I need to have my tabs controller call my smaller charts element controller. I’m not sure if it’s a good idea to call a controller from another one.
We right now have this thing. Connection method in our ApplicationController wrapper. I already posted it in common patterns:
/**
* Get instance of remote controller
* @param controller - controller name
* @param id - instance element ID
*/
connectRemote(controller, id = null) {
const elementId = id || controller
const element = document.getElementById(elementId)
return this.application.getControllerForElementAndIdentifier(element, controller)
}
This case you can fire action on tab content controller via tab button for example.
Adrien showed another example. Please feel free what you like here:
I think it’s no issues to call another controller inside a controller. We don’t build super-duper-reusable single responsibility components, we solving a real problem on the specific page.
At least this is my point when I use Stimulus