Hi,
i need to post a form using AJAX so that I can update and save my
object:
form:
<% form_for(@sample,:html => {:id => “analyses_list”}) do %>
Analyses:
<%= render :partial => 'parameters/parameter_name',
:collection => @parameters %>
<% end %>
if I am using link_to_function in order to post the form, everything
is alright except that it’s not an AJAX request, but at least the
action update is called:
link:
<%= link_to_function(“Remove an analysis from sample # #{@sample.id}”,
“if (confirm(‘Are you sure you want to remove those analyses?’)) $
(‘analyses_list’).submit();”) %>
I try using link to remote, but i have a problem with the url
parameter, i cant get the link to send the request to the update
action.
<%= link_to_remote “Remove analyses from sample” ,{:url => {:action =>
‘update’, :id =>@sample}}, {:confirmation => true,:submit =>
‘analyses_list’} %>
i also tried
{:url => sample_url(@sample), :method => :put}
i already try with
form:
<% remote_form_for(@sample,:html => {:id => “analyses_list”}) do %>
Analyses:
<%= render :partial => 'parameters/parameter_name',
:collection => @parameters %>
<% end %>
link:
<%= link_to_function(“Remove an analysis from sample #
#removed_email_address@domain.invalid}”,
“if (confirm(‘Are you sure you want to remove those analyses?’)) $
(‘analyses_list’).submit();”) %>
but if the update action is correctly done, my update.js.rjs is not
called and i get an error
Missing template samples/update.html.erb in view path F:/Programmation/
ROR/LIMS/app/views
which mean that update is dealing with an regular http request, not
AJAX one. As my link is not in the form itself i assume that is the
link that need to perform the AJAX request, not the form.
On Oct 2, 8:35 am, Frederick C. [email protected]
i finally mange to get it works it was quiet obvious in fact:
link:
<%= link_to_remote “Remove analyses from sample # #{@sample.id}” ,:url
=> {:action => ‘update’, :id=> @sample}, :confirmation => true,:submit
=> ‘analyses_list’ %>
edit:
except that i don’t have a confirmation pop up. ;-(