Skip to content

How to use rails_admin.dom_ready? #3600

Answered by mshibuya
gabrieletassoni asked this question in Q&A
Discussion options

You must be logged in to vote

This is unexpected. And I found that the cause is the custom event name RailsAdmin use.
Currently it's rails_admin.dom_ready (separated by a period), unlike others which uses a colon (e.g. turbo:load for Turbo). And
jQuery interprets a period-separated name as a namespaced event. So jQuery's on will listen to events with the type of rails_admin and the namespace dom_ready, not the event type rails_admin.dom_ready. Hence $(document).on('rails_admin.dom_ready' ...) doesn't get invoked.

I consider this as a regression and will attempt to fix. For now you can work around this by using addEventListener instead of jQuery's on.

document.addEventListener("rails_admin.dom_ready", function () {
   …

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by gabrieletassoni
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants