Ruby on Rails
Wednesday, May 23, 2012
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@gmail.com> wrote:
view.html<%= submit_tag "act",:id => params[:id], :class => "actcpn btn btn-success" %>
.js$(".actcpn").click(function() {$.ajax({type: "PUT",success: function(){$('.nplabel').fadeIn(300).show(); $('.nplabel').fadeOut(3000);}});});class PgmControlllerdef activate@coupon_id = params[:id]endHere 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?Thanksvishnu--
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@googlegroups.com .
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 .
--
- Aziz M. Bookwala
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@googlegroups.com.
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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment