Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kneath/6643 to your computer and use it in GitHub Desktop.
Save kneath/6643 to your computer and use it in GitHub Desktop.
// Examples:
//
// button_to "Mark as unread", mark_as_unread_message_path(message), :method => :put, :class => "form_to_link"
// button_to "New Alert", new_alert
//
jQuery(document).ready(function($) {
jQuery('.form_to_link').each(function(el){
var form = el.parents('form');
form.after('<a href="' + form.attr('action') + '" class="button_link_to">' + form_to_link.attr('value') + '</a>');
form.hide();
el.getElementsBySelector('.button_link_to').click(function(){
form.submit();
return false;
});
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment