Created
August 21, 2008 19:49
-
-
Save zachinglis/6624 to your computer and use it in GitHub Desktop.
Unobtrusively have put and post links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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($) { | |
var form_to_link = jQuery('.form_to_link'); | |
var form = form_to_link.parents('form'); | |
form.after('<a href="' + form.attr('action') + '" class="button_link_to">' + form_to_link.attr('value') + '</a>'); | |
form.hide(); | |
jQuery('.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