Using Stimulus Controllers in Administrate
I'm trying to use a stimulus controller in a custom Administrate field (to load some data from Stripe).
I currently have it all working as a single <script> tag in my field's
Assuming that Stimulus is not included in administrate's js, I added this to
I currently have it all working as a single <script> tag in my field's
_form.html.erb
, but I want to move this to a Stimulus controller.Assuming that Stimulus is not included in administrate's js, I added this to
app/javascripts/administrate/index.js
:import { Application } from 'stimulus' import CourseOfferingsController from './controllers/course_offerings_controller' const application = Application.start() application.register('course-offerings', CourseOfferingsController) console.log("Stimulus registered") console.log("controllers:", application.controllers)
my controller is stubbed out like this:
import { Controller } from "stimulus" export default class extends Controller { static targets = [] initialize() { console.log("stim initialize") } connect() { console.log("stim connect") } test(e) { e.preventDefault() console.log("stimulus") } }
When I load my page I do see the "Stimulus Registered" line, however the controllers array is empty. What am I doing wrong?
Notifications
You’re not receiving notifications from this thread.