Ask A Question

Notifications

You’re not receiving notifications from this thread.

Stimulus not autoloading controllers

RJ McCollam asked in Javascript

Decided to give stimulus a try on a new app I am working on and immediately ran into issues. Up to this point this is a fresh rails 6.1 app and I have installed Hotwire-rails.

Just using the hello example controller that comes by default I get this error in the console - Failed to autoload controller: hello.

What is weird to me is that if I remove the targets array and simply have

connect() {
    console.log('hi')
}

I will get that output in the console. So Stimulus is "working" in a sense, but not the way it should be.

Reply

Turns out this is an issue in Safari, but not in Chrome and Firefox.

Seems like kind of a huge issue and so anti-pattern to the basecamp/DHH way of doing things. Maybe I am missing something though.

Reply

i have a controller named dropdown. and this is my code
import { Controller } from "@hotwired/stimulus"

// Connects to data-controller="dropdown"
export default class extends Controller {
connect() {
alert("hi")
console.log("Hello from Drowpdown")
}
}

i can't see any output in console
rails v = 7.0.2.2
ruby v = 3.0.0

any suggestions?

Reply

Having the same issue, can't test a controller is initializing

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,464+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.