Questions tagged [stimulusjs]

For questions regarding the Stimulus Javascript framework

392 questions
3
votes
2 answers

Dynamically declare Stimulus target types for TypeScript

I'm writing stimulus controllers in TypeScript and I feel like there has to be a better way of declareing all of the has*Target/*Target/*Targets properties than declaring each and every one. Does anyone know if what I'm looking for is even possible?…
M. Wyatt
  • 160
  • 2
  • 10
3
votes
1 answer

Rails 7/StimulusJS relative import: working on dev, but not production

I'm using Rails again after a few years away (last used Rails 4). I have multiple stimulus controllers that reference a file called metric_defaults.js. That file just contains a flat set of definitions such as: Chart.defaults.elements.line.tension =…
PlankTon
  • 12,443
  • 16
  • 84
  • 153
3
votes
1 answer

Fullcalendar displays incorrect

Hi I'm using FullCalendar With bootstrap 5 and Stimulus JS connect() { this.calendar = new Calendar(this.calendarTarget, { plugins: [ dayGridPlugin, timeGridPlugin, listPlugin, bootstrap5Plugin], themeSystem:…
Dev devovs
  • 99
  • 5
3
votes
1 answer

Rails simple_form element with data-... attributes for stimulus?

I am trying to hook up a stimulus controller to a form element which is inside a form generated by the simple form gem. Whatever I do - the corresponding "data-controller" attribute doesn't appear in the final rendered page (and hence, the…
tkhobbes
  • 368
  • 3
  • 16
3
votes
1 answer

fire event from external controller

i'm moving to Rails 7 and i feel like there are so many changes but i'm confident on understanding them and be able to upgrade a personal applications i made myself for keeping my personal records and appointments More specific i need to communicate…
barone
  • 33
  • 4
3
votes
2 answers

Stimulus js Cross Controller events context

I have two, independent, stimulus controllers. One that manages a table and one that is used to trigger a new row for the table. I have a button on the page that calls the turbo-table-new-row#show function, which does dispatch the event and the…
studeba
  • 41
  • 3
3
votes
1 answer

How to use and load JS helpers in Stimulus controllers in Rails 7?

I want to import and use functions from my javascript/helpers/functions.js file in my stimulus controllers. I tried pinning it with: # importmap.rb pin_all_from "app/javascript/helpers", under: "helpers" Add it to the asset precompilation with: #…
3
votes
1 answer

Failed to resolve module specifier "stimulus-autocomplete"

Ruby 3.0.3 Rails 7.0.0.alpha2 After following the instructions to install and usage, I launch the server and I received this error: Uncaught TypeError: Failed to resolve module specifier "stimulus-autocomplete". Relative references must start with…
Guillaume
  • 1,437
  • 2
  • 15
  • 17
3
votes
1 answer

How do I use Leaflet in Rails 7?

What I would like to do: I would like to use Leaflet in a Rails 7 app. What I did: I created my rails app and generated a model (with controller and views) called map with only a title. I then added a single map record. I added leaflet to the app…
3
votes
2 answers

stimulus.js live update field outside of controller

On a rails 6 installation, I have the following: Controller: # app/controllers/foo_controller.rb def bar @items = [["firstname", "{{ FIRSTNAME }}"], ["lastname", "{{ LASTNAME }}"], ["company", "{{ COMPANY }}"]] end View: #…
3
votes
2 answers

Converting typescript to javascript

Is there currently any converters online that could convert ts to js? I would like to use the components from here, but they're all written in ts and my rails app doesn't support it. for example this file import { Controller } from…
Daniel
  • 183
  • 1
  • 7
3
votes
1 answer

Pattern for handling clicks outside an element for a collection in Stimulus JS

New to stimulus and trying to find the correct pattern here. I have a collection of form items with a hidden submit button by default. When you click into the input the submit button reveals. As you click into other inputs the previously active…
computer_smile
  • 2,117
  • 2
  • 24
  • 42
3
votes
1 answer

Stimulus controllers in subfolders not working in Symfony

Good morning. I am experiencing problems with Stimulus controllers and namespaces following the name convention specified in Stimulus documentation. When I use my controllers like this everything works as…
3
votes
1 answer

Error: Void function return value is used

I use Stimulus in Symfony 5 and when I use this code in my Stimulus controller, PhpStorm shows an error. How can I fix this? import {Controller} from 'stimulus'; import {index} from "../js/index"; export default class extends Controller{ …
user15220416
3
votes
1 answer

Having nested elements with the same controller

So i have this case, where i have a list that is hidden by default, and when you click a button it toggles the visibility. this is my controller import { Controller } from "stimulus"; export default class extends Controller { static targets =…
Ahmed Khattab
  • 2,645
  • 2
  • 13
  • 19
1 2
3
26 27