Created
May 7, 2015 09:46
-
-
Save pounard/42bb7f9270ebf596ac08 to your computer and use it in GitHub Desktop.
Tiny JS code (jQuery, sorry guys) - that prevents double click on target forms.
This file contains hidden or 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
// Prevent double click in some forms. | |
(function(jQuery) { | |
"use strict"; | |
Drupal.behaviors.fixDoubleClick = { | |
attach: function (context) { | |
var k, selectors = [ | |
"#comment-form" | |
// Add here forms with problems. | |
]; | |
for (k in selectors) { | |
jQuery(context).find(selectors[k]).on("submit", function () { | |
jQuery(context).find("input[type=submit]").attr({ | |
disabled: "disabled" | |
}); | |
}); | |
} | |
} | |
}; | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh, and that's for Drupal, if you want it generic, replace the Drupal.behavior.fooBar using a nice jQuery(document).ready({ /* ... */ }); instead.