I'm trying to call a stimulus controller action when clicking a button. As I'm seeing, the scope is correct, also the name of the method, and the stimulus controller is actually well registered. Still, I'm getting this output from console. Any thoughts on what the error could be? (Also tried running yarn install and restarting the server but still not working)
<div data-controller="logs">
<a class="button is-info is-outlined ml-2 mb-2" data-action="click->logs#displayGraph" data-logs-target="graph_button">Graph</a>
<div data-logs-target="graph_visualization" class="is-hidden"><h1>GRAPH GOES HERE..</h1></div>
</div>
Here is my stimulus controller...
import { Controller } from "@hotwired/stimulus"
// Connects to data-controller="logs"
export default class extends Controller {
static targets = ["graph_visualization", "graph_button" ]
displayGraph() {
this.graph_visualizationTarget.classList.toggle("is-hidden")
this.graph_buttonTarget.classList.toggle("is-focused")
}
}
Changed my process manager
I was using overmind s, to compile everything and open my project in localhost:5000.
But then, changed to rails s and seemed to worked good!
I'm guessing it has to do with how everything was being compiled, but does someone has a more specific explanation.