Questions tagged [stimulusjs]

For questions regarding the Stimulus Javascript framework

392 questions
20
votes
4 answers

What's the hotwire way of dealing with data-disable-with?

I'm starting to use Hotwire in my Rails app and I implemented something similar to the tutorial video where a form gets submitted and refresh another part of the page. Like in the video, I had to implement my own reset form controller: import…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
14
votes
1 answer

How to pass a data value to a stimulus controller upon a load event

I have a Stimulus controller # app/javascript/controllers/clubs_controller.js // handles micropost javascripts import { Controller } from "stimulus" import Rails from '@rails/ujs'; export default class extends Controller { connect() { } …
Obromios
  • 15,408
  • 15
  • 72
  • 127
13
votes
4 answers

Issue with resetting form after submission using Hotwire & Stimulus.js Rails 6

I've been testing Hotwire, using the demo that was put up by DHH. I have a default rails 6 setup & I know that it re-creates the javascript folder structure from the rails 5 < asset pipeline. The issue I am having is the form will not reset the text…
valcod3r
  • 321
  • 4
  • 14
10
votes
3 answers

Stimulus: how to handle repeating items with the same target name

I have a list of items, and each one has a link to click to edit it. I am using stimulus to make the edit "modal" form visible when they click that edit link. The id of what is going to be edited is present as an id= on the corresponding link tag of…
pitosalas
  • 10,286
  • 12
  • 72
  • 120
9
votes
1 answer

Use Import Maps and Stimulus with Rails 6

I'm currently on Rails 6.0.4 and I want to use Stimulus to build a new page. There's a lot of work still to do before upgrading to Rails 7, so I want to use importmaps and stimulus with Rails 6 if possible. But so far I haven't been able to get a…
9
votes
2 answers

Rails UJS link_to destroy action not working properly after migrating to webpack

I have a project with Rails/webpacker/stimulus. Today I migrated the asset pipeline to webpacker. All went fine except for one detail. Link_to buttons with a call to a destroy method direct to the show action instead. Also the remote:true tag isn't…
8
votes
2 answers

How can I declare a const string in my Stimulus JS controller?

I'm wanting to set a const variable for a CSS selector for my controller, instead of having it hard coded throughout my controller. I had put the declaration in the initialize() of my controller, but I'm getting an error that the variable wasn't…
daveomcd
  • 6,367
  • 14
  • 83
  • 137
7
votes
2 answers

ActionController::UnknownFormat when using format.turbo_stream in Rails 7

Hey I'm new to turbo_streams and am stuck on why I'm getting this error. Properties partial:
6
votes
2 answers

Adding a Stimulus click action to a Turbo link?

I am doing an inline editing feature on the show page with the 'Edit' button above the frame that loads with turbo. Trying to add a toggle on the edit button that it switches to the cancel button in edit mode. Figured a simple stimulus controller…
Dan Tappin
  • 2,692
  • 3
  • 37
  • 77
6
votes
1 answer

How do I Listen to Select2 Events in a Stimulus Controller?

I am trying to listen to a Select2 event in a Stimulus controller via the data-action. I have a stimulus controller, where I have included an event listener for Select2 events, but I cannot listen for the Select2 event from the HTML. import {…
Jesse Farmer
  • 553
  • 4
  • 13
6
votes
2 answers

Input change event is not working with Stimulus nor Vanilla JS

I have a form inside a modal with 3 inputs. The first two are hours and I need to update the value of second hour when the first one change. I've successfully connected the Stimulus controller to the form and I can show it in console. This is my…
João Ramires
  • 723
  • 10
  • 23
5
votes
1 answer

Stimulus not geting values from html

I'm doing a basic controller and trying to get data from the HTML with the tag value. The problem is that the data is always empty
Nonyck
  • 652
  • 1
  • 12
  • 28
5
votes
1 answer

Refresh Turbo Frames with a select without submitting on Rails 7

I'm learning Turbo Frames and Streams + Stimulus so it's possible I'm not 100% on track. I have a form for creating a new object, but within the form I'd like to have a select component that will display certain fields depending on the selection.…
5
votes
1 answer

Stimulus JS Controllers not connecting to Rails App

I'm working on a Rails 7.0.2 App with Ruby 3.0.2 and I'm following the stimulus tutorial for making a clipboard copy button https://stimulus.hotwired.dev/handbook/hello-stimulus .When I press the button nothings happened and I've over ridden my…
CJG
  • 457
  • 2
  • 17
5
votes
2 answers

Rails 7 + importmap + fullcalendar

I've manage to include bootstrap 5 without any issues, but when I try to include fullcalendar I get this error on browser console: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of…
letz
  • 1,762
  • 1
  • 20
  • 40
1
2 3
26 27