Guest User

Untitled

a guest
Jul 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. ## extension.rb
  2.  
  3. module UpdatedHelper
  4. def link_to label, path, options = {}
  5. if options.has_key?(:disable_with]
  6. options[:html] ||= { }
  7. options[:html].merge! "data-disable" => options[:disable_with]
  8. end
  9.  
  10. super label, path, options
  11. end
  12. end
  13.  
  14. ## jquery [javascript]
  15.  
  16. jQuery(document).ready(function() {
  17. jQuery(":submit[data-disable=*]").click(function(event) {
  18. event.preventDefault();
  19.  
  20. this.setAttribute('originalValue', this.value);
  21. this.disabled = true;
  22. this.value='Please wait...';
  23. var result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());
  24.  
  25. if (result == false) {
  26. this.value = this.getAttribute('originalValue');
  27. this.disabled = false;
  28. }
  29.  
  30. return result;
  31. });
  32. });
Add Comment
Please, Sign In to add comment