Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
Submitting a Remote Form via rails-ujs

I'm slowly modernizing a legacy Rails app, and am trying to swap out jquery-ujs for rails-ujs.

I've installed rails-ujs via the asset pipeline, and know that this is working as expected: in my browser's console, I've got access to the Rails object.

But, when I try to use the Rails.fire event to submit a form, I can't get the expected behavior.

In my view:

<%= form_with model: post, method: :PUT, url: post_update_url(post), local: false, html: { data: { target: "posts.form", action: "ajax:success->posts#submitSuccess" } } do |f| %>
  // Form stuff
<% end %>

In my Stimulus controller:

submit() {
  Rails.fire(this.formTarget, 'submit');
}

submitSuccess() {
  console.log("Success!")
}

If I remove local: false, then the form submits just as expected, and the page re-loads. But as soon as we add AJAX back, Rails.fire() simply returns false. How would I update this to programmatically submit this form remotely?

(Note that my Stimulus controllers are managed via Webpacker, while rails-ujs is installed via the asset pipeline. Due to constraints within my app, I would like to avoid rails-ujs via Webpacker right now, if possible.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!