Guest User

Untitled

a guest
Feb 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. // Examples:
  2. //
  3. // HTML:
  4. // <form action='messages/1/mark_unread'><input type='submit' class='button_to_link' value='Mark Unread'/></form>
  5. //
  6. // Rails:
  7. // button_to "Mark as unread", mark_as_unread_message_path(message), :method => :put, :class => "button_to_link"
  8. //
  9. // jQuery:
  10. // $(document).ready(function() {
  11. // $('.button_to_link').button_to_link()
  12. // });
  13. //
  14. jQuery.fn.button_to_link = function() {
  15. // return the jQuery object for chaining
  16. return this.each(function(button){
  17. var form = button.parents('form');
  18. form.after('<a href="' + form.attr('action') + '" class="button_link_to">' + button.attr('value') + '</a>');
  19. form.hide();
  20.  
  21. form.next('a.button_link_to').click(function(){
  22. form.submit();
  23. return false;
  24. });
  25. })
  26. });
  27.  
  28. // Or you could just use a button and style it.
Add Comment
Please, Sign In to add comment