Vikas Gholap
2009-Sep-18 08:23 UTC
How to get value from link_to_remote''s :with paramenter?
Hello, I have following code in my view -------------------------------------------------------------- #plan_discount %table %tr %td ="Discount Code" %td =text_field_tag ''discount_code'' %td =link_to_remote "Apply", :update => "result", :url => { :action => "discount_code"}, :with => "''discount=''+ $(discount_code).value" #result //Here I display processed value based on value entered in "discount_code" //textfield ------------------------------------------------------------------ When user enter the value in discount code textfield, I process it and display it in "result" div My problem is that in controllers How can I get value of "discount" which is passed as a parameter in above link_to_remote function def discount_code discount_code = params[:discount] # I tried this , but get nil value puts discount_code render :text => discount_code end What is the right way to do this? Thanks, Vikas -- Posted via http://www.ruby-forum.com/.
Sijo Kg
2009-Sep-18 10:48 UTC
Re: How to get value from link_to_remote''s :with paramenter?
Hi Vikas Gholap Either "''discount=''+$(''discount_code'').value" Or "''discount=''+$F(''discount_code'')" Sijo -- Posted via http://www.ruby-forum.com/.
Vikas Gholap
2009-Sep-19 03:46 UTC
Re: How to get value from link_to_remote''s :with paramenter?
Sijo Kg wrote:> Hi Vikas Gholap > > Either > > "''discount=''+$(''discount_code'').value" > Or > > "''discount=''+$F(''discount_code'')" > > > > SijoThanks Sijo, But I don''t have problem related to this. My question is that how i access "discount" parameter value in controller. using discount_value = params[:discount] gives me nil. How can i access paramter value passed in ":with" Thanks again, Vikas -- Posted via http://www.ruby-forum.com/.
robdoan
2009-Sep-19 08:20 UTC
Re: How to get value from link_to_remote''s :with paramenter?
I think the correct is : link_to_remote "Apply", :update => "result", :url => { :action => "discount_code"}, :with => "discount=$ (discount_code).value" On Sep 19, 10:46 am, Vikas Gholap <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Sijo Kg wrote: > > Hi Vikas Gholap > > > Either > > > "''discount=''+$(''discount_code'').value" > > Or > > > "''discount=''+$F(''discount_code'')" > > > Sijo > > Thanks Sijo, > > But I don''t have problem related to this. > > My question is that how i access "discount" parameter value in > controller. > > using discount_value = params[:discount] gives me nil. > > How can i access paramter value passed in ":with" > > Thanks again, > Vikas > -- > Posted viahttp://www.ruby-forum.com/.
robdoan
2009-Sep-19 08:46 UTC
Re: How to get value from link_to_remote''s :with paramenter?
sorry it''s : :with=>"''discount=''+$(''discount_code'').value" . You missed single quote in discount_code :) On Sep 19, 10:46 am, Vikas Gholap <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Sijo Kg wrote: > > Hi Vikas Gholap > > > Either > > > "''discount=''+$(''discount_code'').value" > > Or > > > "''discount=''+$F(''discount_code'')" > > > Sijo > > Thanks Sijo, > > But I don''t have problem related to this. > > My question is that how i access "discount" parameter value in > controller. > > using discount_value = params[:discount] gives me nil. > > How can i access paramter value passed in ":with" > > Thanks again, > Vikas > -- > Posted viahttp://www.ruby-forum.com/.
Sijo Kg
2009-Sep-21 04:50 UTC
Re: How to get value from link_to_remote''s :with paramenter?
Hi Is it solved? Once more try exact this Cannot see anyother error. link_to_remote "Apply", :update => "result", :url => {:action => "discount_code"}, :with => "''discount=''+$(''discount_code'').value" And in controller params[:discount] Sijo -- Posted via http://www.ruby-forum.com/.
Vikas Gholap
2009-Sep-21 05:01 UTC
Re: How to get value from link_to_remote''s :with paramenter?
Quy Doan wrote:> sorry it''s : > :with=>"''discount=''+$(''discount_code'').value" . > You missed single quote in discount_code :) > > On Sep 19, 10:46�am, Vikas Gholap <rails-mailing-l...@andreas-s.net>Thanks, but how can i pass multiple parameters through :with option in link_to_remote for example =link_to_remote "Apply", :update => "plan_discount", :url => { :action => "discount_code"}, :with=>"''discount=''+$(''discount_code'').value &''discount2=''+$(''discount_code2'').value" This is not working. Where I''m doing wrong. -- Posted via http://www.ruby-forum.com/.
Sijo Kg
2009-Sep-21 05:19 UTC
Re: How to get value from link_to_remote''s :with paramenter?
Hi Vikas :with =>"''discount=''+ escape($(''discount_code'').value) + ''&discount2='' + escape($(''discount_code2'').value)" Sijo -- Posted via http://www.ruby-forum.com/.
Vikas Gholap
2009-Sep-21 06:59 UTC
Re: How to get value from link_to_remote''s :with paramenter?
Sijo Kg wrote:> Hi Vikas > > :with =>"''discount=''+ escape($(''discount_code'').value) + ''&discount2='' + > escape($(''discount_code2'').value)" > > > > SijoHello Sijo Thanks, but it is not working. For only one parameter it is working fine, but not for more than one parameter. There is syntax error, but i tried it various ways, failed. Following is my link_to_remote function =link_to_remote "Apply", :update => "plan_discount", :url => { :action => "discount_code"}, :with =>"''discount=''+ escape($(''discount_code'').value) + ''&tariff_plan='' + escape($(''tariff_plan_id'').value)" HTML generated from above is <a onclick="new Ajax.Updater(''plan_discount_result'', ''/subscriptions/discount_code'', {asynchronous:true, evalScripts:true, parameters:''discount=''+ escape($(''discount_code'').value) + ''&tariff_plan='' + escape($(''tariff_plan_id'').value) + ''&authenticity_token='' + encodeURIComponent(''FgSc9EashXK3rPds+Y31d0emXvwRRAQyEoWq1ksyH90='')}); return false;" href="#">Apply</a> -- Posted via http://www.ruby-forum.com/.
Sijo Kg
2009-Sep-21 08:04 UTC
Re: How to get value from link_to_remote''s :with paramenter?
Hi It should work.And what error you get? Also paste the code for textfields discount_code and tariff_plan_id Sijo -- Posted via http://www.ruby-forum.com/.
Vikas Gholap
2009-Sep-21 08:23 UTC
Re: How to get value from link_to_remote''s :with paramenter?
Sijo Kg wrote:> Hi > > It should work.And what error you get? Also paste the code for > textfields discount_code and tariff_plan_id > > > Sijo"tariff_plan_id" is a redio button and "discount_code" is a textfield %input{:type=>''radio'', :name=>''tariff_plan_id'', :value=>"#{plan[''service''][''name''].downcase}_#{plan[''payment_term''][''name''].downcase}"} =text_field_tag ''discount_code'' =link_to_remote "Apply", :update => "plan_discount", :url => { :action => "discount_code"}, :with =>"''discount=''+ escape($(''discount_code'').value) + ''&tariff_plan=''+ escape($(''tariff_plan_id'').value)" When I click on "Apply" link, nothing happens. Thanks, Vikas -- Posted via http://www.ruby-forum.com/.
Sijo Kg
2009-Sep-21 08:45 UTC
Re: How to get value from link_to_remote''s :with paramenter?
H Vikas> %input{:type=>''radio'', :name=>''tariff_plan_id'', > :value=>"#{plan[''service''][''name''].downcase}_#{plan[''payment_term''][''name''].downcase}"}Give also give an id to this id=>''tariff_plan_id'' Sijo -- Posted via http://www.ruby-forum.com/.
Vikas Gholap
2009-Sep-21 09:38 UTC
Re: How to get value from link_to_remote''s :with paramenter?
Sijo Kg wrote:> H Vikas >> %input{:type=>''radio'', :name=>''tariff_plan_id'', >> :value=>"#{plan[''service''][''name''].downcase}_#{plan[''payment_term''][''name''].downcase}"} > > Give also give an id to this id=>''tariff_plan_id'' > > > > SijoYes, by giving id to radio button it works. But I have 5 radio_button with group "tariff_plan_id". If i give same id to all of them, there is problem of having same id for 5 radio buttons. and I think this is not correct. - service[''all_plans''].each do |plan| %input{:type=>''radio'', :id => "tariff_plan_id_#{plan[''service''][''name''].downcase}_#{plan[''payment_term''][''name''].downcase}", :name=>''tariff_plan_id'', :value=>"#{plan[''service''][''name''].downcase}_#{plan[''payment_term''][''name''].downcase}"} here for each plan one radio button is generated. So another problem arises that how i know that which radio button is selected from "tariff_plan_id" group. if consider 5 radio buttons are there (may be increased in feature) then I have to specify tariff_plan_id_1 tariff_plan_id_2 tariff_plan_id_3 tariff_plan_id_4 tariff_plan_id_5 Thanks, Vikas -- Posted via http://www.ruby-forum.com/.