Using ujs ajax events with stimulus actions
See original GitHub issueFirst of all, thank you for Stimulus – it’s great.
I’m wondering if it is possible currently or planned to be able to bind to ujs ajax events with stimulus’s action binding syntax.
I have a modal I want to close on an ajax:success
event after the modal’s form is submitted . Placing the data attribute data: {action: 'ajax:success->modal#close'}
on the form doesn’t seem to bind, or I haven’t been able to suss out my error.
It’s no problem to bind it manually once the controller is connected, but the action syntax is pretty nifty.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Using ujs ajax events with stimulus actions · Issue #78 - GitHub
I'm wondering if it is possible currently or planned to be able to bind to ujs ajax events with stimulus's action binding syntax....
Read more >How to combine Rails's Ajax support and Stimulus
In this post I'm going to explain how we are exploring adding snappier SPA-like interactivity to the Admin and what we've learned so...
Read more >Stimulus and Rails UJS - Hotwire Discussion
You can use all the rails-ujs request lifecycle events on your actions, so if you need to perform some logic before the request...
Read more >Stimulus and Ajax. Modern Front-End Development for Rails…
The simplest mechanism for making Ajax calls in modern JavaScript is with the fetch function and the async/await syntax for handling ...
Read more >Stimulus and Ajax - Modern Front-end Development for Rails
Learn to use Stilumus and Ajax in this lesson. ... The Rails UJS library provides an ajax method, but the fetch function is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As @lsylvester says, you’ll need to make sure to use
rails-ujs
, which emits regular DOM events instead of jQuery events.@mmlindeboom Are you using
jquery_ujs
orrails-ujs
UJS adapter? I don’t have any problems listening to ajax:* events when usingrails-ujs
but I get nothing when usingjquery_ujs
, I think cause they are jquery events instead of dom events.