Giter Site home page Giter Site logo

Comments (5)

lsylvester avatar lsylvester commented on September 27, 2024 3

@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.

sstephenson avatar sstephenson commented on September 27, 2024 3

As @lsylvester says, you’ll need to make sure to use rails-ujs, which emits regular DOM events instead of jQuery events.

from stimulus.

cursorzz avatar cursorzz commented on September 27, 2024 2

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.

mmlindeboom avatar mmlindeboom commented on September 27, 2024

Thank you!

from stimulus.

kaspermeyer avatar kaspermeyer commented on September 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.