HI THERE, In my .rhtml file I have some links.I need to invoke a ruby method(controller''s method/Helper method) and send link text as a parameter on clicking the link. Is it Possible..! Thanks In Advance -- 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Thorsten Mueller
2008-Jun-02 13:51 UTC
Re: sending parameters to ruby method from javascript
sure:
link_to("my_text", { :action => "your_action",
:some_param => "my_text"
})
this would give you "my_text" as params[:some_param] in your action.
You
can add any number of parameters that way with whatever content you
want.
--
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-/JYPxA39Uh5TLH3MbocFFw@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
-~----------~----~----~----~------~----~------~--~---
Pavankumar Kulkarni
2008-Jun-02 14:11 UTC
Re: sending parameters to ruby method from javascript
Yes it is possible. link_to_function(name, *args, &block) Returns a link that will trigger a JavaScript function using the onclick handler and return false after the fact. The function argument can be omitted in favor of an update_page block, which evaluates to a string when the template is rendered (instead of making an Ajax request first). (Refer http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M001061 ) Thanks -Pavan On Mon, Jun 2, 2008 at 6:51 AM, Thorsten Mueller <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > sure: > > link_to("my_text", { :action => "your_action", :some_param => "my_text" > }) > > this would give you "my_text" as params[:some_param] in your action. You > can add any number of parameters that way with whatever content you > want. > -- > 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Ravinder Pandiri
2008-Jun-03 06:58 UTC
Re: sending parameters to ruby method from javascript
Thanks for the reply..
I am sorry for asking the question in the worst way.My question
is
can I pass a javascript variable to a Ruby Method call.?
Thank You.
Pavankumar Kulkarni wrote:> Yes it is possible.
>
> link_to_function(name, *args, &block)
>
> Returns a link that will trigger a JavaScript function using the
> onclick handler and return false after the fact.
>
> The function argument can be omitted in favor of an update_page block,
> which evaluates to a string when the template is rendered (instead of
> making an Ajax request first).
>
> (Refer
>
http://api.rubyonrails.com/classes/ActionView/Helpers/JavaScriptHelper.html#M001061
> )
>
> Thanks
> -Pavan
>
> On Mon, Jun 2, 2008 at 6:51 AM, Thorsten Mueller
--
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-/JYPxA39Uh5TLH3MbocFFw@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
-~----------~----~----~----~------~----~------~--~---