Where would you suggest placing Stimulus controllers? How would you “share” the application object across the different _controller.js files if you are working with an application manifest with a require_tree?
Were you ever able to find a good solution for sharing the application instance across the controller files? I’m starting a new project and need to find a good solution. Thanks!
I’ve been using Stimulus in a Rails app that still uses Sprockets, where I managed to organize the controllers in separate folders and files without the use of Webpacker. The trick is to attach the running Stimulus application to the window object, which makes it accessible across multiple files.
First, ensure that you’ve installed the sprockets-es6 gem in the project if you want to use Babel and that Stimulus is added before the application manifest inside <head>:
I have a question how i can import external library for example bootstrap-datepicker from Js or using Javascript librarys is importing in application.js
I try this
stimulus.register(“wizard”, class extends Stimulus.Controller {
import datepicker from “bootstrap-datepicker”
})
But dont working I trying to use in Rails 4 very old proyect