Hi !
The ActionView::Helpers::JavaScriptHelper#form_remote_tag[1]
documentation says that we can use the same callbacks as
ActionView::Helpers::JavaScriptHelper#link_to_remote[2]. I''m trying to
trigger something on success from an AJAX form submission.
All events are triggered, except for :success. Here''s my form
declaration:
<%= form_remote_tag({:update => ''phones-list'',
:url => {:action => :ajax_add_phone},
:success =>
''alert("Success");''}) %>
The generated code looks like:
<form action="/estimates/ajax_add_phone" method="post"
onsubmit="new Ajax.Updater(''phones-list'',
''/estimates/ajax_add_phone'', {asynchronous:true,
evalScripts:true,
parameters:Form.serialize(this)}); return false;">
(cleaned up for E-Mail)
First question is: does the success event really exist ?
ActionView::Helpers::JavaScriptHelper::CALLBACKS does not mention the
existence of a :success callback.
Looking at the code, I believe :success should be passed to :update (in
a Hash), but this is for updating a DOM element, right ? (look at line
238+ in the Rails 0.13.1 distribution, 246 in trunk@HEAD). What if I
want some other code to run in addition ?
I want to verify my thoughts before I submit a patch.
Thanks !
François
[1]
http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M000397
[2]
http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M000395