Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda