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
we recently added stimulus to our application and began using outlets shortly thereafter.
We could not help but wonder why outlets are matched by selector instead of by controller name.
I assumed that you could add multiple batches of outlets using the same controller like so:
<!-- before --><divdata-controller="users"
data-users-user-outlet=".user"
><!-- after --><divdata-controller="users"
data-users-admin-outlet=".admin"
data-users-moderator-outlet=".moderator"
>
(given that .admin and .moderator both use UserController).
I discovered today that this is not possible, because stimulus checks that the controller name matches the name of the outlet.
Now my question: Why did you choose to introduce a selector in the first place?
We ended up setting the selector to [data-controller="user"], because we don't want to introduce any none-style related classes into our html.
Matching by controller would allow for a much clearer syntax like:
which would not only be much easier to understand (I personally find the current example in the documentation confusing), but also grant the opportunity to supply multiple outlets in one attribute (just like we do in the data-controller attribute).
Please let me know if I'm missing something here.
I'd be glad to work on this, should it be taken into consideration.
The text was updated successfully, but these errors were encountered:
Hi folks,
we recently added stimulus to our application and began using outlets shortly thereafter.
We could not help but wonder why outlets are matched by selector instead of by controller name.
I assumed that you could add multiple batches of outlets using the same controller like so:
(given that
.admin
and.moderator
both useUserController
).I discovered today that this is not possible, because stimulus checks that the controller name matches the name of the outlet.
Now my question: Why did you choose to introduce a selector in the first place?
We ended up setting the selector to
[data-controller="user"]
, because we don't want to introduce any none-style related classes into our html.Matching by controller would allow for a much clearer syntax like:
which would not only be much easier to understand (I personally find the current example in the documentation confusing), but also grant the opportunity to supply multiple outlets in one attribute (just like we do in the
data-controller
attribute).Please let me know if I'm missing something here.
I'd be glad to work on this, should it be taken into consideration.
The text was updated successfully, but these errors were encountered: