Obtener referencia de objeto de formulario remoto enviado

In Rails I want to know which form was last submitted via javascript (). I want to hide it on completition.

= simple_form_for @user, :remote => true do |f| ...

In jQuery I would normally do something like this:

$("form").submit(function() { last_submitted_form = $(this) }

In format.js response I would write: last_submitted_form.hide();

Is there a better way to do it in rails since I also lazy load bootstrap modals with form objects and use Turbolinks gem?

preguntado el 28 de enero de 14 a las 18:01

1 Respuestas

Eche un vistazo a ajax:* custom events in Rails UJS (https://github.com/rails/jquery-ujs/wiki/ajax)

Something like in your app js code (not tested)

$("form").on('ajax:complete', function() { $(this).hide() });

Deberia trabajar.

Respondido el 28 de enero de 14 a las 18:01

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.