Can anyone tell me which are the possible observer_form callbacks? I am working on an old Rails application which I have migrated from Rails 2 to Rails 3. Application contains observers like field_observer and form_observer.
I want to add a condition when a form gets submitted by a user through this form and if the condition satisfied then only send Ajax request otherwise terminate the request.
I want to do something like this:
<%= observe_form lrv.simple_form_id,
:before => "Element.show('big_spinner')",
:failure => "alert('Failed AJAX update.')",
:complete => "Element.hide('big_spinner')",
:condition => "CallerMethod.show_event_confirmation(#{confirmation_required?(lrv)})",
:url => { :action => :update, lodging_group_reservation: true }
-%>
I have tried condition but it works only with link_to_remote and not working with observer_form.
I have tried submit observer but it throws error like
TypeError: $(...) is null
var elements = $(form).getElementsByTagName('*'),
This is may be because I have added different ID but it is required because there are many forms on this page.
Aucun commentaire:
Enregistrer un commentaire