Reputation: 112
I have a form_tag
form that I want to submit in order to get the values. These same values I want to use in a javascript that is triggered by the same submit button I use for the form.
What I want to do is to first submit the form and then call the javascript.
My submit function looks like that:
<%= submit_tag "Submit", :onclick => "sendRequestToRecipients(); return false;" %>
but it only calls the javascript and doesn't submit the form.
If I do something like this:
:onclick => "submit();sendRequestToRecipients(); return false;"
then I only submit the form but don't call the javascript.
Can I somehow say "trigger this javascript after the form is submitted(using the result of the submission)?
My javascript looks like that:
function sendRequestToRecipients() { { options } , requestCallback); }
Upvotes: 0
Views: 127
Reputation: 1734
The problem is the return false which prevents the default action of the submit button.
Try:
<%= submit_tag "Submit", :onclick => "sendRequestToRecipients();" %>
Upvotes: 1