Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Examples:
- //
- // HTML:
- // <form action='messages/1/mark_unread'><input type='submit' class='button_to_link' value='Mark Unread'/></form>
- //
- // Rails:
- // button_to "Mark as unread", mark_as_unread_message_path(message), :method => :put, :class => "button_to_link"
- //
- // jQuery:
- // $(document).ready(function() {
- // $('.button_to_link').button_to_link()
- // });
- //
- jQuery.fn.button_to_link = function() {
- // return the jQuery object for chaining
- return this.each(function(button){
- var form = button.parents('form');
- form.after('<a href="' + form.attr('action') + '" class="button_link_to">' + button.attr('value') + '</a>');
- form.hide();
- form.next('a.button_link_to').click(function(){
- form.submit();
- return false;
- });
- })
- });
- // Or you could just use a button and style it.
Add Comment
Please, Sign In to add comment