You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a use case where users can manage "permission groups", which can have multiple "attachments". I modeled this by having a permission-group-form controller that handles general logic and permission-group-form--attachment controller that handles logic within a single attachment row.
I want to create an attachments outlet on the permission-group-form controller. However, since Stimulus requires outlet names to match the controller name, I have to call the outlet permission-group-form--attachment. This means I have to declare it like this:
And in the controller I have a lot of repetition as well:
// app/javascript/controllers/permission_group_form_controller.jsimport{Controller}from"@hotwired/stimulus"exportdefaultclassextendsController{staticoutlets=["permission-group-form--attachment"// I want just "attachment"]connect(){this.permissionGroupFormAttachmentOutlets// I want just "attachmentOutlets"}}
Proposed solution
I wanted to propose the ability to choose a custom name for outlets, and map them to the Stimulus controller. The API could look something like this:
Problem
I have a use case where users can manage "permission groups", which can have multiple "attachments". I modeled this by having a
permission-group-form
controller that handles general logic andpermission-group-form--attachment
controller that handles logic within a single attachment row.I want to create an
attachments
outlet on thepermission-group-form
controller. However, since Stimulus requires outlet names to match the controller name, I have to call the outletpermission-group-form--attachment
. This means I have to declare it like this:And in the controller I have a lot of repetition as well:
Proposed solution
I wanted to propose the ability to choose a custom name for outlets, and map them to the Stimulus controller. The API could look something like this:
And then the DOM declaration would be a lot simpler as well:
The text was updated successfully, but these errors were encountered: