Patrick McCafferty
2006-Mar-13 11:18 UTC
[Rails] How to apply an effect to a link_to_remote :update without using evaluate_remote_response?
Hey all, I''ve been trying to apply a slide-down (or highlight) effect to a "New card" link on my application. Because the item is *new* and I''m simply updating it at the top, I can''t know what the div id is before I make the request. link_to_remote :complete => visual_effect(:slidedown) doesn''t do what I want it to do. My current solution is: <%= link_to_remote ''New card'', :url => { :action => ''new_card'', :id => @stack.id }, :complete => evaluate_remote_response %> and then new_card returns JS: new Insertion.Top(''cards'', ''<%= escape_javascript(render(:partial => "editcard", :locals => { :editcard => @card }))%>''); new Effect.SlideDown(''card<%= @card.id %>''); but this just feels horribly, horribly wrong, because I can NOT be the only person to ever need to do this. I know for sure that 37signals had to do it, for that matter. What I want to do is: <%= link_to_remote ''New card'', :url => { :action => ''new_card'', :id => @stack.id }, :update => ''cards'', :position => :top, :complete => visual_effect(:slidedown) %> and then just render the partial in the controller. But this doesn''t give me good results. Am I just stuck returning JS this way? It seems awkward. Thanks, Patrick
Jonathan Viney
2006-Mar-13 11:28 UTC
[Rails] How to apply an effect to a link_to_remote :update without using evaluate_remote_response?
Using RJS will make it cleaner: View: <%= link_to_remote ''New card'', :url => { :action => ''new_card'', :id => @ stack.id } %> new_card.rjs: page.insert_html :top, ''cards'', :partial => ''editcard'', :object => @card page.visual_effect :slide_down, "card#{@card.id}" That should do what you''re after. To use RJS you need to be using edge rails, or the plugin which is around somewhere. Just google for it. -Jonathan. On 3/14/06, Patrick McCafferty <ryouga@gmail.com> wrote:> > > Am I just stuck returning JS this way? It seems awkward.-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060313/8c503850/attachment.html
Patrick McCafferty
2006-Mar-13 21:26 UTC
[Rails] How to apply an effect to a link_to_remote :update without using evaluate_remote_response?
Ah, I see, and I found the plugin as well :) That does make it a lot cleaner. Thanks. Luckily TxD has edge rails on it, or I can just keep using 1.0 :) On 3/13/06, Jonathan Viney <jonathan.viney@gmail.com> wrote:> Using RJS will make it cleaner: > > View: > > <%= link_to_remote ''New card'', :url => { :action => ''new_card'', :id => > @stack.id } %> > > > new_card.rjs: > > page.insert_html :top, ''cards'', :partial => ''editcard'', :object => @card > page.visual_effect :slide_down, "card#{@card.id}" > > That should do what you''re after. To use RJS you need to be using edge > rails, or the plugin which is around somewhere. Just google for it. > -Jonathan. > > > On 3/14/06, Patrick McCafferty <ryouga@gmail.com> wrote: > > > > Am I just stuck returning JS this way? It seems awkward. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >