Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow using events used by rails-ujs #415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

CPatchane
Copy link
Contributor

@CPatchane CPatchane commented May 30, 2023

Based on the code source https://github.com/rails/rails/blob/main/actionview/app/assets/javascripts/rails-ujs.js

This is not compatible with jquery-ujs since the custom event (like ajax:success) listeners signature are changing from jquery-ujs to rails-ujs:

  • jQueryUJS, by using .trigger() from jQuery, makes the listener signature looking like onSuccess(event: Event, data: any) => { console.log(data) }
  • in contrast, RailsUJS missing jQuery, is now using the native Event API with .dispatchEvent() and a CustomEvent making the listener looking like onSuccess(event: CustomEvent<any>) => { console.log(event.detail) }

jquery-ujs source
rails-ujs source

@CPatchane CPatchane self-assigned this May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant