I would really appreciate some help with changing a link_to_remote call to a button of some sort. Here''s a little background. On the page there are two <div>s. One is a form that lets the visitor enter items. The second <div> is where the entered items get displayed, each in it''s own item <div>. Each item <div> has two <span>s. The first one displays the item description as entered in the form. The second <span> contains a link_to_remote that allows the removal of the item from the database in the controller action and then removal of the item <div> from the page using RJS. As I understand the discussion in AWDwR (p. 335-7), a visitor who has the Google Web Accelerator (GWA) installed is going to have a real problem unless I change the link_to_remote to a button. As I understand it, every time they add an item, GWA is going to follow that link and remove what they just added. First, can anybody confirm (or even better, correct my understanding) that that''s the way GWA is going to work? Second, assuming I''ve got a real problem, has anybody got any ideas about how to make this change? I''ve experimented a bit and the situation right now, using button_to, is that the controller gets called and the database record gets deleted. When the RJS template gets called, however, and sends the JS to the browser to remove the item <div> from the page, instead of executing the JS, the browser intercepts it and asks if I want to save it. I don''t understand why or what I need to do to make this change work. Sure would appreciate some help on this. Thanks in advance, Bill -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060720/d19a11d5/attachment.html
On 7/21/06, Bill Walton <bill.walton@charter.net> wrote:> > I would really appreciate some help with changing a link_to_remote call > to a button of some sort. Here''s a little background. > > On the page there are two <div>s. One is a form that lets the visitor > enter items. The second <div> is where the entered items get displayed, > each in it''s own item <div>. > > Each item <div> has two <span>s. The first one displays the item > description as entered in the form. The second <span> contains a > link_to_remote that allows the removal of the item from the database in the > controller action and then removal of the item <div> from the page using > RJS. > > As I understand the discussion in AWDwR (p. 335-7), a visitor who has the > Google Web Accelerator (GWA) installed is going to have a real problem > unless I change the link_to_remote to a button. As I understand it, every > time they add an item, GWA is going to follow that link and remove what they > just added. > > First, can anybody confirm (or even better, correct my understanding) that > that''s the way GWA is going to work? > > Second, assuming I''ve got a real problem, has anybody got any ideas about > how to make this change? I''ve experimented a bit and the situation right > now, using button_to, is that the controller gets called and the database > record gets deleted. When the RJS template gets called, however, and sends > the JS to the browser to remove the item <div> from the page, instead of > executing the JS, the browser intercepts it and asks if I want to save it. > I don''t understand why or what I need to do to make this change work. > > Sure would appreciate some help on this. > > Thanks in advance, > Bill > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsI don''t understand what''s happening with GWA but have you tried wrapping your button in a form_remote_tag? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060720/85b6e42c/attachment.html
Hi Daniel,> Daniel N wrote:> On 7/21/06, Bill Walton <bill.walton@charter.net> wrote: > > I would really appreciate some help with changing a > > link_to_remote call to a button of some sort.> have you tried wrapping your button in a form_remote_tag?No I haven''t. And I''m not sure I understand the suggestion. Do you mean wrapping or replacing? If I could wrap it, which I don''t think I can since, AFAIK, I can''t have a form within a form, it seems like that would give me two buttons. OTOH, I''ll take a look at the syntax for form_remote_tag and see if that might work. Thanks for the suggestion! Best regards, Bill
On 7/21/06, Bill Walton <bill.walton@charter.net> wrote:> > Hi Daniel, > > > Daniel N wrote: > > > On 7/21/06, Bill Walton <bill.walton@charter.net> wrote: > > > I would really appreciate some help with changing a > > > link_to_remote call to a button of some sort. > > > have you tried wrapping your button in a form_remote_tag? > > No I haven''t. And I''m not sure I understand the suggestion. Do you mean > wrapping or replacing? If I could wrap it, which I don''t think I can > since, > AFAIK, I can''t have a form within a form, it seems like that would give me > two buttons. OTOH, I''ll take a look at the syntax for form_remote_tag and > see if that might work. Thanks for the suggestion! > > Best regards, > Bill > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsIf you are placing the button into the form then I''m not sure that you can put another form just around the button. I''m guessing a bit here but I think you should be able to use the remote_function method to get a remote function attached to the button, this is basically the same as a link_to_remote call <%= button_to_function "A name", remote_function( :url => { :action => ''my_action'', :controller => ''my_controller'', :id => 2 }, :update => ''my_div'' ), {:class => ''a_css_class''} %> Hope that works :) -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060720/dd9814f5/attachment.html
Bill Walton
2006-Jul-20 15:47 UTC
RESOLVED Re: [Rails] Need HELP changing link_to_remote to a button
Hi Daniel, Daniel N wrote: On 7/21/06, Bill Walton <bill.walton@charter.net> wrote:> Hi Daniel,> > Daniel N wrote:> > On 7/21/06, Bill Walton <bill.walton@charter.net> wrote: > > > I would really appreciate some help with changing a > > > link_to_remote call to a button of some sort.> > have you tried ... a form_remote_tag?> I''ll take a look at the syntax for form_remote_tag and > see if that might work. Thanks for the suggestion!It worked like a charm. SWEET!!! Thanks _very_ much for your suggestion! For future readers.... As long as the following line is not contained within a form... <%= link_to_remote("Remove", :url => {:action => ''destroy'', :id => @this_allergy.id}) %> it can be replaced with the following to avoid the look-ahead, link-following issues caused by client-side agents like Google Web Accelerator. <%= form_remote_tag( :url => {:action => ''destroy'', :id => @this_allergy.id}) %> <%= submit_tag "Remove" %> <%= end_form_tag %> Best regards, Bill
Kevin Olbrich
2006-Jul-20 15:58 UTC
RESOLVED Re: [Rails] Need HELP changing link_to_remote to a button
On Thursday, July 20, 2006, at 10:47 AM, Bill Walton wrote:>Hi Daniel, > >Daniel N wrote: > >On 7/21/06, Bill Walton <bill.walton@charter.net> wrote: >> Hi Daniel, > >> > Daniel N wrote: > >> > On 7/21/06, Bill Walton <bill.walton@charter.net> wrote: >> > > I would really appreciate some help with changing a >> > > link_to_remote call to a button of some sort. > >> > have you tried ... a form_remote_tag? > >> I''ll take a look at the syntax for form_remote_tag and >> see if that might work. Thanks for the suggestion! > >It worked like a charm. SWEET!!! Thanks _very_ much for your suggestion! > >For future readers.... > >As long as the following line is not contained within a form... > ><%= link_to_remote("Remove", :url => {:action => ''destroy'', :id => >@this_allergy.id}) %> > >it can be replaced with the following to avoid the look-ahead, >link-following issues caused by client-side agents like Google Web >Accelerator. > ><%= form_remote_tag( :url => {:action => ''destroy'', :id => >@this_allergy.id}) %> ><%= submit_tag "Remove" %> ><%= end_form_tag %> > >Best regards, >Bill > >_______________________________________________ >Rails mailing list >Rails@lists.rubyonrails.org >http://lists.rubyonrails.org/mailman/listinfo/railsI think you may also be able to do this... <%= link_to_remote("Remove", :url => {:action => ''destroy'', :id => @this_allergy.id}, {:post=>true}) %> Which, IIRC, will prevent GWA from following the link. _Kevin www.sciwerks.com -- Posted with http://DevLists.com. Sign up and save your mailbox.