Hello, On one of my pages I''ve got a button which should do various stuff based on some params passed to the page (and some retrieved from the session). I was doing it fine using an helper : def action_button product if logged_in? button_to "Already added!",{:action=>:show, :id=>product}, elsif @cart.items.include? product button_to "Already added!",{:controller=>''store''},{:disabled=>true} else button_to "Add to cart", {:action=>:add_to_cart, :id=>product} end end But now I''d like to start using some eye-candy effects with Ajax. So I tried to write down this : def action_button product if logged_in? button_to "Already added!",{:action=>:show, :id=>product}, elsif @cart.items.include? product button_to "Already added!",{:controller=>''store''},{:disabled=>true} else to_return = '''' form_remote_tag :url => {:action=>:add_to_cart,:id=>product} do to_return += submit_tag "Add to cart" end to_return end end But it didn''t work. Turns out that "form_remote_tag" needs to call _erbout which is only defined in the view, but not in the helpers ... Do you know how I could fix my problem (without putting too much stuff in my views) ? Thanks a lot -- 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 -~----------~----~----~----~------~----~------~--~---
On 10/5/07, Stefano Grioni <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > But now I''d like to start using some eye-candy effects with Ajax. So I > tried to write down this : > > def action_button product > if logged_in? > button_to "Already added!",{:action=>:show, :id=>product}, > elsif @cart.items.include? product > button_to "Already > added!",{:controller=>''store''},{:disabled=>true} > else > to_return = '''' > form_remote_tag :url => {:action=>:add_to_cart,:id=>product} do > to_return += submit_tag "Add to cart" > end > to_return > end > end > > But it didn''t work. Turns out that "form_remote_tag" needs to call > _erbout which is only defined in the view, but not in the helpers ... Do > you know how I could fix my problem (without putting too much stuff in > my views) ?Don''t use a block with form_remote_tag in this case. You want something like this: form_remote_tag(:url => ...blah...) + submit_tag(''Add to cart'') + end_form_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-/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 -~----------~----~----~----~------~----~------~--~---
Thanks, it works perfectly -- 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 -~----------~----~----~----~------~----~------~--~---
bhbrinckerhoff wrote:> Any ideas on how to do this now that end_form_tag is deprecated? > > Thanks! > > On Oct 6 2007, 6:18 am, Stefano Grioni <rails-mailing-l...@andreas-Hi, I have a scenario wherein i have opened a javascript popup window, now i want the user to do some actions in that window, and now the form from the window is submited, on submit i call a method that does the server side handling and then on success i call the window.close and now on complete i am trying to invoke another ajax call to update a dom element in the main window. My code looks like this <%= form_remote_tag :method=>''post'', :url=>{:action =>''add_from_pop_up'', :count => count}, :success => "window.close();", :complete => "javascript:test(count)"%> and the javascript fcn is function test(count) { qs = "count="+ count new Ajax.Request(''/reporting/update_div'', {parameters:qs, asynchronous:true, evalScripts:true}); return false; } Any suggestions on how to invoke this javascript method to update a DOM element. Neha -- 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 -~----------~----~----~----~------~----~------~--~---