*view.html* <%= submit_tag "act",*:id => params[:id]*, :class => "*actcpn* btn btn-success" %> *.js* * * $(".*actcpn*").click(function() { $.ajax({ type: "PUT", url: "http://localhost:3000/pgm/activate/", success: function(){ $(''.nplabel'').fadeIn(300).show(); $(''.nplabel'').fadeOut(3000); } }); }); *class PgmControlller* def activate * * @coupon_id = params[:id] end Here the problem is i need to get the params[:id] in controller. so when the *act* button click in view, that will call the ajax through class .* actcpn,* where i give the url to the controller,How to pass that button id via that ajax url to controller? Thanks vishnu -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/2gzWsZv8J0UJ. 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.
Hey! Can you be a little clearer about what you are trying to accomplish? On Wed, May 23, 2012 at 11:48 AM, amvis <vgrkrishnan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> *view.html* > > <%= submit_tag "act",*:id => params[:id]*, :class => "*actcpn* btn > btn-success" %> > > *.js* > * > * > $(".*actcpn*").click(function() { > $.ajax({ > type: "PUT", > url: "http://localhost:3000/pgm/activate/", > success: function(){ > $(''.nplabel'').fadeIn(300).show(); > $(''.nplabel'').fadeOut(3000); > } > }); > }); > > *class PgmControlller* > def activate > * * @coupon_id = params[:id] > end > Here the problem is i need to get the params[:id] in controller. so when > the *act* button click in view, that will call the ajax through class .* > actcpn,* where i give the url to the controller,How to pass that button > id via that ajax url to controller? > > Thanks > vishnu > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/2gzWsZv8J0UJ. > 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. >-- - Aziz M. Bookwala Website <http://azizmb.in/> | Twitter <https://twitter.com/azizbookwala> | Github <http://github.com/azizmb> -- 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.
On Wednesday, 23 May 2012 02:32:59 UTC-4, azizmb.in wrote:> > Hey! > > Can you be a little clearer about what you are trying to accomplish? > >yes, in my project, the view file is pgm.html.erb, that have one button *pgm.html.erb* * * * * <%= submit_tag "*activate*",*:id => params[:id]*, :class => "*actcpn* btn btn-success" %> Here the *controller* * *class PgmsController def cpn_activate *@cpn_id = params[:id]* * puts "b_id#{@cpn_id}"* end end *header.js* * * $("*.actcpn*").click(function() { $.ajax({ type: "PUT", url: "http://localhost:3000/pgms/cpn_activate/", success: function(){ $(''.nplabel'').fadeIn(300).show(); $(''.nplabel'').fadeOut(3000); } }); }); i have one button in pgm.html.erb, that button name is *activate*, so when i click on that button, that will call one ajax with the class id (*actcpn*), in that ajax function, i have specified the url: * "http://localhost:3000/pgms/cpn_activate/"* to controller, In that controller i have to get the button id, which i pass *:id => params[:id]*, through button....... So how to pass that button ID via the url from the ajax..?> > > > > > > On Wed, May 23, 2012 at 11:48 AM, amvis <vgrkrishnan-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> *view.html* >> >> <%= submit_tag "act",*:id => params[:id]*, :class => "*actcpn* btn >> btn-success" %> >> >> *.js* >> * >> * >> $(".*actcpn*").click(function() { >> $.ajax({ >> type: "PUT", >> url: "http://localhost:3000/pgm/activate/", >> success: function(){ >> $(''.nplabel'').fadeIn(300).show(); >> $(''.nplabel'').fadeOut(3000); >> } >> }); >> }); >> >> *class PgmControlller* >> def activate >> * * @coupon_id = params[:id] >> end >> Here the problem is i need to get the params[:id] in controller. so when >> the *act* button click in view, that will call the ajax through class .* >> actcpn,* where i give the url to the controller,How to pass that button >> id via that ajax url to controller? >> >> Thanks >> vishnu >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rubyonrails-talk/-/2gzWsZv8J0UJ. >> 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. >> > > > > -- > - Aziz M. Bookwala > > Website <http://azizmb.in/> | Twitter <https://twitter.com/azizbookwala> > | Github <http://github.com/azizmb> > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/njjYtJjZekgJ. 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.
amvis wrote in post #1061789:> On Wednesday, 23 May 2012 02:32:59 UTC-4, azizmb.in wrote: > *header.js* > * > * > $("*.actcpn*").click(function() { > $.ajax({ > type: "PUT", > url: "http://localhost:3000/pgms/cpn_activate/", > success: function(){ > $(''.nplabel'').fadeIn(300).show(); > $(''.nplabel'').fadeOut(3000); > } > }); > }); > ... > So how to pass that button ID via the url from the ajax..?You pass the parameter the same way you always do with HTTP. Put it in the query string or request body. JQuery makes this easy using the "data" attribute: $.ajax({ type: ''PUT'', url: url, data: data, success: success, dataType: dataType }); data - A map or string that is sent to the server with the request. -- 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-/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.
Robert Walker wrote in post #1062048:> You pass the parameter the same way you always do with HTTP. Put it in > the query string or request body. JQuery makes this easy using the > "data" attribute: > > $.ajax({ > type: ''PUT'', > url: url, > data: data, > success: success, > dataType: dataType > }); > > data - A map or string that is sent to the server with the request.I forgot one other possible location. The data/attribute could be part of the URL itself, as is often the case with Rails routes (i.e. http://localhost:3000/pgms/cpn_activate/1 #where 1 is the id). P.S. That''s a pretty ugly URL for a Rails app by the way. Maybe you should consider cleaning that up. Start with not abbreviating so much. If "pgms" means "programs" then have a Program model and "/programs/:action/:id" for the route. Search engines will also appreciate having actual words in the URL. The more clear the intent the better. We''re not in danger of running out of letters on the web. -- 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-/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.