I''ve changed my destructive link_to statements in favor of button_to. But what if I want to make an .rjs call with that button? Seems like we need something equivalent to link_to_remote, so that the button can make an ajax request instead submitting the form. Or am I missing the point entirely? Jeff --~--~---------~--~----~------------~-------~--~----~ 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''ve changed my destructive link_to statements in favor of button_to. > > But what if I want to make an .rjs call with that button? > > Seems like we need something equivalent to link_to_remote, so that the > button can make an ajax request instead submitting the form.button_to takes a javascript function... so pass in an ajax function to call using remote_function.... http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M000534 -philip --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Jeff, Jeff wrote:> I''ve changed my destructive link_to statements in > favor of button_to. > > But what if I want to make an .rjs call with that button? > > Seems like we need something equivalent to link_to_remote, > so that the button can make an ajax request instead submitting > the form.I''ve made pretty extensive use of form_remote_tag for this. I just don''t put any user input elements inside, although I do sometimes put hidden fields inside to pass param values. Just be aware that you can''t use it inside another form like you can with link_to_remote. hth, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Philip, Philip Hallstrom wrote:> button_to takes a javascript function... so pass in > an ajax function to call using remote_function....Could you say more about this, please? What do you mean "button_to takes a javascript function"? I wasn''t able to find anything about that when I went though the exercise. I still don''t see it but would really like to know how it could be made to work. A snippet would be excellent! Thanks, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Amos.L.King-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-24 15:00 UTC
Re: Is there such a thing as button_to_remote?
I''ve been working on much the same problem, but I have a form that when I submit it I want to only reload part of the page. I tried working it like I have other ajax/RJS calls, but it doesn''t seem to work from a submit_tag. I don''t know the name of the javascript function that the rjs creates so I don''t know how to call it. --~--~---------~--~----~------------~-------~--~----~ 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 Mar 23, 4:44 pm, "Bill Walton" <bill.wal...-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote:> I''ve made pretty extensive use of form_remote_tag for this. I just don''t > put any user input elements inside, although I do sometimes put hidden > fields inside to pass param values. Just be aware that you can''t use it > inside another form like you can with link_to_remote.Maybe you can help me with a related question, then... when I try a simple remote form like this: <% form_remote_tag(:url => products_path, :html => { :id => ''product_form'' }) do %> <h2>Add Product</h2> <label for="product_title">Title:</label> <%= text_field ''product'', ''title'' %> <%= submit_tag "Add New Product" %> <% end %> This will call my create action just fine as expected; but unfortunately it will respond_to html, not js, and hence render the wrong template! Is this the correct behavior? I don''t think it is. Did I do something wrong in the above code? Thanks again, Jeff --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, def button_to_remote(name, options = {}, html_options = {}) button_to_function(name, remote_function(options), html_options) end Cheers, John On Mar 25, 2:23 am, "Jeff" <cohen.j...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Mar 23, 4:44 pm, "Bill Walton" <bill.wal...-xwVYE8SWAR3R7s880joybQ@public.gmane.org> wrote: > > > I''ve made pretty extensive use of form_remote_tag for this. I just don''t > > put any user input elements inside, although I do sometimes put hidden > > fields inside to pass param values. Just be aware that you can''t use it > > inside another form like you can with link_to_remote. > > Maybe you can help me with a related question, then... when I try a > simple remote form like this: > > <% form_remote_tag(:url => products_path, :html => { :id => > ''product_form'' }) do %> > <h2>Add Product</h2> > <label for="product_title">Title:</label> > <%= text_field ''product'', ''title'' %> > <%= submit_tag "Add New Product" %> > <% end %> > > This will call my create action just fine as expected; but > unfortunately it will respond_to html, not js, and hence render the > wrong template! Is this the correct behavior? I don''t think it is. > Did I do something wrong in the above code? > > Thanks again, > Jeff--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Jeff, Jeff wrote:> when I try a simple remote form like this: > > <% form_remote_tag(:url => products_path, > :html => { :id => ''product_form'' }) do %> > <h2>Add Product</h2> > <label for="product_title">Title:</label> > <%= text_field ''product'', ''title'' %> > <%= submit_tag "Add New Product" %> > <% end %> > > This will call my create action just fine as expected; but > unfortunately it will respond_to html, not js, and hence > render the wrong template! Is this the correct behavior?Sorry, but I''m not sure I''m following you. I''m guessing you''re saying you''re using respond_to in your create action and that it''s rendering an RHTML template instead of the RJS template you expect. Is that right? If so, the problem is probably in how you''ve coded the respond_to. I took me some time to get my arms around that. A little sandbox time goes a long way. Create a new sandbox, cut the code down to the bare minimum needed to get the behavior that you''re testing. If you''re still in need, I''m happy to take a look at the controller and view code at that point if you want to post it. Best regards, Bill I don''t think it is.> Did I do something wrong in the above code? > > Thanks again, > Jeff > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 will call my create action just fine as expected; but > > unfortunately it will respond_to html, not js, and hence > > render the wrong template! Is this the correct behavior?Also make sure that you''ve included the required javascript in your layout. Something like: <%= javascript_include_tag :defaults %> If I remember correctly I was having a similar problem to yours and the reason was that I wasn''t including javascript. Jesse --~--~---------~--~----~------------~-------~--~----~ 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 Mar 25, 10:44 am, "Jesse Grosjean" <jesse.grosj...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Also make sure that you''ve included the required javascript in your > layout. Something like: > > <%= javascript_include_tag :defaults %>Yes, that was it! Unforunately I didn''t even see your reply until the day after I figured it out (stupid Google Groups strikes again). Thanks so much. Jeff --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jeff Cohen wrote:> I''ve changed my destructive link_to statements in favor of button_to. > > But what if I want to make an .rjs call with that button? > > Seems like we need something equivalent to link_to_remote, so that the > button can make an ajax request instead submitting the form. > > Or am I missing the point entirely? > > Jeffsubmit_to_remote -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
isn''t the whole point of button_to to make sure you support non-JS users? [well, mebbe not the whole point.] ;) you could probably just add custom js to a regular button_to and have both rjs fun and not leave non-JS users out in the cold. RSL On Thu, Jul 17, 2008 at 6:48 AM, Ricardo Villalobos <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Jeff Cohen wrote: >> I''ve changed my destructive link_to statements in favor of button_to. >> >> But what if I want to make an .rjs call with that button? >> >> Seems like we need something equivalent to link_to_remote, so that the >> button can make an ajax request instead submitting the form. >> >> Or am I missing the point entirely? >> >> Jeff > > submit_to_remote > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Maybe Matching Threads
- Need HELP changing link_to_remote to a button
- Using an image button for "link_to_remote"
- syntax for specifying :html fallback on form_remote_tag
- respond_to not detecting JS turned on. form_to_remote problem?
- problem trying to update multiple <DIV> elements with AJAX