Reputation: 429
May I know, can we achieve "Page-Specific Javascript" loading as mentioned in Organizing Javascript in Rails Application With Turbolinks article using the stimulusjs framework ?
Thanks.
Upvotes: 1
Views: 702
Reputation: 360
Yes, though it's more "component-specific".
With Stimulus, you can add data-controller
to any element, and at any time that elements is in the DOM, appropriate controller will be invoked. No need for $(document).ready
or $(document).on("turbolinks:load")
— everything happens automatically.
You can read more in Stimulus Handbook.
Upvotes: 1