Comments (5)
@mmlindeboom Are you using jquery_ujs
or rails-ujs
UJS adapter? I don't have any problems listening to ajax:* events when using rails-ujs
but I get nothing when using jquery_ujs
, I think cause they are jquery events instead of dom events.
from stimulus.
As @lsylvester says, you’ll need to make sure to use rails-ujs
, which emits regular DOM events instead of jQuery events.
from stimulus.
how could I use rails-ujs in webpacker? [edited]
I find the solution for myself. but leave a reference for someone has same question like mine
If you're using the Webpacker gem or some other JavaScript bundler, add the following to your main JS file:
import Rails from 'rails-ujs';
Rails.start()
reference: https://github.com/rails/rails/tree/master/actionview/app/assets/javascripts#es2015
PS: rails 5 has ujs build-in
from stimulus.
Thank you!
from stimulus.
If you are working on a project where you can't switch from jquery_ujs
to rails-ujs
, I've proposed a solution here:
https://gist.github.com/kaspermeyer/7fe28bb7c55c2810e7b5f3d5e67c1a44
I did a small write-up about it on the Stimulus Discourse:
https://discourse.stimulusjs.org/t/listening-to-jquery-events-on-stimulus-actions/573
from stimulus.
Related Issues (20)
- Callback Ordering Inconsistency in Documentation HOT 1
- disconnect() not called if outlet is accessed in connect() HOT 6
- Expired certificate on a CDN HOT 1
- Wrong params passed to action when multiple actions from multiple controllers HOT 4
- Progress bar keeps on loading forever
- Question about Stimulus' life cycle HOT 2
- Conflicting Fetch between stimulus and Hotwire HOT 4
- Discussion/Questions: Hotwire and Client Side Rendering HOT 5
- Value declared with a {type: String} but no default value behave like they have a default value
- This.element is showing a previous (cached?) version of the DOM element HOT 1
- Turbo Drive: Stimulus doesn't disconnect/connect after redirection to same URL HOT 3
- Support multiple keystroke binds for KeyboardEvent Filter
- Stimulus controllers imported twice, Initialize and clickEvents firing twice HOT 5
- Outlets do not disconnect when removed via morph
- work with BigInt HOT 2
- classList.remove() doesn't do anything on target HOT 4
- [v3.2.2] Input type "date" and "datetime-local" do not display initial value HOT 3
- Load failed errors when sending fetch requests in Safari on iOS devices. HOT 1
- Value changed fires without reflecting a change HOT 2
- Outlets property name in nested controller path
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stimulus.