Having an outer controller that controls inner controller

00

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 :slight_smile:

2 Likes