I'm trying to replace a Submit button in a form with a javascript function. I'm able to insert the following link_to_function for submitting the form:
<%= link_to_function 'Create', "$('form').submit()" %>
Now, I want to replace the default form submit button with the js function above with jquery to have a fallback option when js is disabled. The question is now:
how do I replace the ordinary submit button inside my application.js file?
I tried:
$('input:submit').replaceWith("<%= escape_javascript(link_to_function 'Create', "$('form').submit()") %>");
which doesn't seem to work :/