Hello, I need to execute an action when the user click a button but I don''t want the page to be reloaded. Is there any way to call a controller action without reloading? Olivier. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
AJAX. Rails 3: link_to ...., :remote => true Rails 2.*: link_to_remote .... Garrett Lancaster> ------------------------------------------------------------------------ > > CiriusMex <mailto:ciriusmex-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > January 11, 2011 12:57 PM > > > Hello, I need to execute an action when the user click a button but I > don''t want the page to be reloaded. Is there any way to call a > controller action without reloading? > > Olivier. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello Garrett, Ok, the link is actually a form submit button, how do I use this remote options on a form submit? On 11 ene, 13:04, Garrett Lancaster <glanc...-jmyiO2ngOJdad6c/EObmYVaTQe2KTcn/@public.gmane.org> wrote:> AJAX. > Rails 3: link_to ...., :remote => true > Rails 2.*: link_to_remote .... > > Garrett Lancaster > > > > > ------------------------------------------------------------------------ > > > CiriusMex <mailto:cirius...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > January 11, 2011 12:57 PM > > > Hello, I need to execute an action when the user click a button but I > > don''t want the page to be reloaded. Is there any way to call a > > controller action without reloading? > > > Olivier.- Ocultar texto de la cita - > > - Mostrar texto de la cita --- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Same syntax in the form. form_for @whatever, :remote => true submit_tag -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ok, let''s see. My form declaration is: <% form_for :support, @support, :url => { :controller => "concepts", :action => "sendContactMail", :id => 0, :type_id => @contactType.id, :property_id => @property.id, :remote => true } do | fContact| %> ..... <%= fContact.submit "Enviar mensaje", :onclick => "return validateInterestedForm();" %> <% end %> Setting the remote as shown above doesn''t seems to work, what would be the right form? Another question, in the action that will be executed (senContactMail) must I set something special (I guess I have to remove the redirect_to but is there anything else I have to do?). Thanks for your help, I never used AJAX before and am actually quite interested in learning how to use it. On 11 ene, 14:15, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Same syntax in the form. > > form_for @whatever, :remote => true > > submit_tag-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
The remote is part of the form not the url. Put it outside the url section. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tried: <% form_for :support, @support, :url => { :controller => "concepts", :action => "sendContactMail", :id => 0, :type_id => @contactType.id, :property_id => @property.id }, :remote => true do | fContact| %> And: <% form_for :support, @support, :url => { :controller => "concepts", :action => "sendContactMail", :id => 0, :type_id => @contactType.id, :property_id => @property.id }, :html => { :remote => true } do |fContact| %> Without success. On 11 ene, 14:24, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> The remote is part of the form not the url. Put it outside the url section.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Get it out of the hash, it is a stand alone value. <% form_for :support, @support, :url => { :controller => "concepts", :action => "sendContactMail", :id => 0, :type_id => @contactType.id, :property_id => @property.id }, :remote => true do |fContact| %> -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That was actually my first try and it didn''t result...I changed the form tag for "form_remote_tag" and got the folloowing form tag generated: <form action="/concepts/sendContactMail/0? property_id=18&type_id=3" method="post" onsubmit="new Ajax.Request(''/concepts/sendContactMail/0? property_id=18&type_id=3'', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"> But the page is still reloaded. On 11 ene, 14:34, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Get it out of the hash, it is a stand alone value. > > <% form_for :support, @support, :url => { :controller => > "concepts", :action => "sendContactMail", :id => 0, :type_id => > @contactType.id, :property_id => @property.id }, :remote => > true do |fContact| %>-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Let''s clarify, this may help. My site present diferente kind of properties. In the "properties/show" page I have a jquery modal the user can use to fill a few informations and send a mail. The mail is sent using the "sendContactMail" action of the "concepts" controller. So the idea is using an AJAX form so the "concepts/sendContactMail" action is executed and send the mail with the user information and the "properties/show" page is not reloaded. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Well you could always just do: button_to_function "submit", remote_function(:url => { } ) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Ok, the "form_remote_for" helper works great, my mistake, didn''t have the prototype.js file imported... Thanks a lot for the help! On 11 ene, 15:01, Me <chabg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Well you could always just do: > > button_to_function "submit", remote_function(:url => { } )-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.