hi, i would like to change a partial in my view with the change of the item in a select_tag: in the view: <%= observe_field("payment_id", :url => {:controller =>''user_admins'' ,:action => ''rend_part''},:on => ''change'', :frequency => 0.1) %> <%= select( "payment", "id", { "Visa" => "1", "Mastercard" => "2"}) %> in controller : def rend_part if params[:payment][''id''] == ''1'' render :partial => "patial_one" else render :partial => "patial_two" end end -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Davis
2011-Apr-30 15:06 UTC
Re: change patial with change of the item in a select_tag
On Apr 29, 2011, at 8:43 AM, Adel Mediouni wrote:> hi, > i would like to change a partial in my view with the change of the > item in a select_tag: > > in the view: > > <%= observe_field("payment_id", :url => {:controller > =>''user_admins'' ,:action => ''rend_part''},:on => ''change'', :frequency > => 0.1) %> > <%= select( "payment", "id", { "Visa" => "1", "Mastercard" => "2"}) %> > > in controller : > > def rend_part > > if params[:payment][''id''] == ''1'' > render :partial => "patial_one" > else > render :partial => "patial_two" > > end > end >And what happens when you do this? Does it work? Have you got a function in place to update the page? In long-hand Prototype.js code, this would look something like this: $(''my_picker'').observe(''change'',function(evt){ new Ajax.Request(''rend_part'',{ parameters:{ payment_id:$F(''my_picker'')}, onSuccess:function(transport){ $(''some_div'').replace(transport.responseText); } } }); }); How you go about doing this with the Ajax helpers is an exercise for the student... Walter> -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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 > . >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Adel Mediouni
2011-May-02 13:44 UTC
Re: change patial with change of the item in a select_tag
when i did it,it doesent work :s so im trying a way to do it !! and about your function,i dont undersand it :/ it mean i add this code to prototype.js and int the observer_fied i call it ? On Apr 30, 5:06 pm, Walter Davis <wa...-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> On Apr 29, 2011, at 8:43 AM, Adel Mediouni wrote: > > > > > > > > > > > hi, > > i would like to change a partial in my view with the change of the > > item in a select_tag: > > > in the view: > > > <%= observe_field("payment_id", :url => {:controller > > =>''user_admins'' ,:action => ''rend_part''},:on => ''change'', :frequency > > => 0.1) %> > > <%= select( "payment", "id", { "Visa" => "1", "Mastercard" => "2"}) %> > > > in controller : > > > def rend_part > > > if params[:payment][''id''] == ''1'' > > render :partial => "patial_one" > > else > > render :partial => "patial_two" > > > end > > end > > And what happens when you do this? Does it work? Have you got a > function in place to update the page? > > In long-hand Prototype.js code, this would look something like this: > > $(''my_picker'').observe(''change'',function(evt){ > new Ajax.Request(''rend_part'',{ > parameters:{ > payment_id:$F(''my_picker'')}, > onSuccess:function(transport){ > $(''some_div'').replace(transport.responseText); > } > } > }); > > }); > > How you go about doing this with the Ajax helpers is an exercise for > the student... > > Walter > > > > > > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > > . > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en > > .-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.