image_to_function in Rails
- by FCastellanos
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!