Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Last active November 13, 2015 18:10
Show Gist options
  • Save walterdavis/b527211b12ab111245a9 to your computer and use it in GitHub Desktop.
Save walterdavis/b527211b12ab111245a9 to your computer and use it in GitHub Desktop.
<%= form_for @foo do |f| %>
<%= f.text_field :name %>
<%= f.text_field :color %>
<%= f.submit 'Save' %>
<%= f.email_field :friend %>
<%= f.submit 'Semd to a friend', formaction: params.merge(action: 'send_to_friend') %>
<%- end -%>
<script type="text/javascript">
if(! ('formAction' in document.createElement('input') ){
document.addEventListener('click', function(evt){
var action = evt.target.getAttribute('formaction');
if(action && evt.target.form){
evt.target.form.action = action;
}
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment