Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## extension.rb
- module UpdatedHelper
- def link_to label, path, options = {}
- if options.has_key?(:disable_with]
- options[:html] ||= { }
- options[:html].merge! "data-disable" => options[:disable_with]
- end
- super label, path, options
- end
- end
- ## jquery [javascript]
- jQuery(document).ready(function() {
- jQuery(":submit[data-disable=*]").click(function(event) {
- event.preventDefault();
- this.setAttribute('originalValue', this.value);
- this.disabled = true;
- this.value='Please wait...';
- var result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());
- if (result == false) {
- this.value = this.getAttribute('originalValue');
- this.disabled = false;
- }
- return result;
- });
- });
Add Comment
Please, Sign In to add comment