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
%>
<b>Analyses:</b>
<ul id="params_list">
<%= render :partial => ''parameters/parameter_name'',
:collection => @parameters %>
</ul>
<% 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}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On 2 Oct 2008, at 15:21, da991319 wrote:> > 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 %> > <b>Analyses:</b> > <ul id="params_list"> > <%= render :partial => ''parameters/parameter_name'', > :collection => @parameters %> > </ul> > <% 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:Why not remote_form_for? Fred> > > 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} > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
i already try with
form:
<% remote_form_for(@sample,:html => {:id => "analyses_list"})
do %>
<b>Analyses:</b>
<ul id="params_list">
<%= render :partial => ''parameters/parameter_name'',
:collection => @parameters %>
</ul>
<% end %>
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();") %>
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 Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> On 2 Oct 2008, at 15:21, da991319 wrote:
>
>
>
>
>
> > 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 %>
> > <b>Analyses:</b>
> > <ul id="params_list">
> > <%= render :partial =>
''parameters/parameter_name'',
> > :collection => @parameters %>
> > </ul>
> > <% 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:
>
> Why not remote_form_for?
>
> Fred
>
>
>
> > 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}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
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'' %>
On Oct 2, 8:59 am, da991319
<castaingre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> i already try with
>
> form:
>
> <% remote_form_for(@sample,:html => {:id =>
"analyses_list"}) do %>
> <b>Analyses:</b>
> <ul id="params_list">
> <%= render :partial =>
''parameters/parameter_name'',
> :collection => @parameters %>
> </ul>
> <% end %>
>
> 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();") %>
>
> 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 Cheung
<frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:
>
> > On 2 Oct 2008, at 15:21, da991319 wrote:
>
> > > 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 %>
> > > <b>Analyses:</b>
> > > <ul id="params_list">
> > > <%= render :partial =>
''parameters/parameter_name'',
> > > :collection => @parameters %>
> > > </ul>
> > > <% 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:
>
> > Why not remote_form_for?
>
> > Fred
>
> > > 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}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
edit: except that i don''t have a confirmation pop up. ;-( On Oct 6, 8:41 am, da991319 <castaingre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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'' %> > > On Oct 2, 8:59 am, da991319 <castaingre...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > i already try with > > > form: > > > <% remote_form_for(@sample,:html => {:id => "analyses_list"}) do %> > > <b>Analyses:</b> > > <ul id="params_list"> > > <%= render :partial => ''parameters/parameter_name'', > > :collection => @parameters %> > > </ul> > > <% end %> > > > 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();") %> > > > 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 Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > On 2 Oct 2008, at 15:21, da991319 wrote: > > > > > 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 %> > > > > <b>Analyses:</b> > > > > <ul id="params_list"> > > > > <%= render :partial => ''parameters/parameter_name'', > > > > :collection => @parameters %> > > > > </ul> > > > > <% 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: > > > > Why not remote_form_for? > > > > Fred > > > > > 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}--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---