image_to_function in Rails
Posted
by FCastellanos
on Stack Overflow
See other posts from Stack Overflow
or by FCastellanos
Published on 2010-06-06T01:36:53Z
Indexed on
2010/06/06
1:42 UTC
Read the original article
Hit count: 304
ruby-on-rails
|ruby
I have this method on rails so that I have an image calling a javascript function
def image_to_function(name, function, html_options = {})
html_options.symbolize_keys!
tag(:input, html_options.merge({
:type => "image", :src => image_path(name),
:onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + "#{function};"
}))
end
I grabbed this code from the application helper of the redmine source code, the problem I'm having is that when I click on the image it's sending a POST, does some one know how can I stop that?
This is how I'm using it
<%= image_to_function "eliminar-icon.png", "mark_for_destroy(this, '.task')" %>
Thanks alot!
© Stack Overflow or respective owner