I want an AJAX form to become part of the page when an item is clicked (I have this part working.) However, I am stumped at what should be really easy. I want my form to have a "save" and a "cancel" button. I have the "save" button working just fine. The "cancel" basically calls a "cancel" action that replaces the AJAX form with what was there. (or at least that is what it does in my head.) Do I have to create a second form that only has the cancel button in it? Or do I need to style both buttons as links? Or is there a better way? Thanks in advance, Alan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Depending on what you want it to look like you can use either link_to_remote ''text to display'', :url=>... or button_to_function ''button text'', :function=>remote_function(:url=>...) In either case, the url refers to the action that will render your original block are remove the form. On Apr 18, 5:12 pm, "Alan Smith" <alan0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I want an AJAX form to become part of the page when an item is clicked > (I have this part working.) > > However, I am stumped at what should be really easy. I want my form > to have a "save" and a "cancel" button. > > I have the "save" button working just fine. > > The "cancel" basically calls a "cancel" action that replaces the AJAX > form with what was there. (or at least that is what it does in my > head.) > > Do I have to create a second form that only has the cancel button in > it? Or do I need to style both buttons as links? Or is there a > better way? > > Thanks in advance, > > Alan--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This is probably obvious to everyone else, but I found what I thought was a VERY elegant solution to this problem: <div id=<%=''"item:''+@item.id.to_s + ''"'' %>> stuff I wanted to go away here... </div> <input type="button" value="Cancel" <%= "onclick=$(''item:" + @item.id.to_s + "'').remove();" %>> I am hope this is helpful to someone else.... --Alan On Fri, Apr 18, 2008 at 8:22 PM, AndyV <AndyVanasse-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Depending on what you want it to look like you can use either > > link_to_remote ''text to display'', :url=>... > > or > > button_to_function ''button > text'', :function=>remote_function(:url=>...) > > In either case, the url refers to the action that will render your > original block are remove the form. > > > > On Apr 18, 5:12 pm, "Alan Smith" <alan0...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I want an AJAX form to become part of the page when an item is clicked > > (I have this part working.) > > > > However, I am stumped at what should be really easy. I want my form > > to have a "save" and a "cancel" button. > > > > I have the "save" button working just fine. > > > > The "cancel" basically calls a "cancel" action that replaces the AJAX > > form with what was there. (or at least that is what it does in my > > head.) > > > > Do I have to create a second form that only has the cancel button in > > it? Or do I need to style both buttons as links? Or is there a > > better way? > > > > Thanks in advance, > > > > Alan > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---