[Rails] Re: run simple method from Helper on button click
The `button_to_function` method's second argument should be JavaScript, not Ruby.
-- See: http://api.rubyonrails.org/classes/ActionView/Helpers/JavaScriptHelper.html#method-i-button_to_function
On Sunday, October 27, 2013 10:27:29 AM UTC-6, Ruby-Forum.com User wrote:
On Sunday, October 27, 2013 10:27:29 AM UTC-6, Ruby-Forum.com User wrote:
Greetings,
I'm new to rails and currently having couple problems about how to add
javascript functionality into rails.
I have a simple method in the helper and i want to run this code on
button click.
----------------------------------------------------------- -------
module PagesHelper
def show_message
"simple output"
end
end
----------------------------------------------------------- -------
this doesnt work
<%= button_to_function "Print", "show_message()" %>
this doesnt work too
<input onclick=" show_message() " type="button" value="PRINT" />
Can someone please show to properly solve this problem? I would really
apreciate it! thank you!
--
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 unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/41a92d2b-1941-497a-a64d-18b7018bde80%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home