Posted on 2012-12-30
I have a Ruby-on-Rails web application in which I need to have more than one submit_tag (or any type of button) call the same function - WITHOUT having to do an actual submit.
I can do this with one submit_tag like so...
<% submit_tag "Call JS Function", :id => "call_js_function" %>
//Do stuff - function is indeed called
However, this doesn't work with more than one submit_tag - since I can't give two submit_tags the same ID.
So, I though maybe onclick might work. So far, I've seen dozens of examples of how to user onclick; none of them have actually worked - although maybe I'm just not using it correctly.
//try to do stuff here - but it never gets executed
And I try to call it using the onclick attribute. However, none of these seem to work:
So far, none of these work.
Thanks in advance,