[Jifty-commit] r1163 - in jifty: trunk/share/web/static/js

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Jun 5 14:16:51 EDT 2006


Author: nelhage
Date: Mon Jun  5 14:16:48 2006
New Revision: 1163

Modified:
   jifty/   (props changed)
   jifty/trunk/share/web/static/js/jifty.js

Log:
 r6840 at phanatique:  nelhage | 2006-06-05 13:30:29 -0400
 First pass at disabling all form inputs related to an action when we
 submit the action, to prevent double-submits.
 


Modified: jifty/trunk/share/web/static/js/jifty.js
==============================================================================
--- jifty/trunk/share/web/static/js/jifty.js	(original)
+++ jifty/trunk/share/web/static/js/jifty.js	Mon Jun  5 14:16:48 2006
@@ -389,6 +389,8 @@
     show_wait_message();
     var named_args = arguments[0];
 
+    disable_fields_for_actions(named_args['actions']);
+    
     // The YAML/JSON data structure that will be sent
     var request = $H();
 
@@ -608,6 +610,21 @@
         new Effect.Fade('jifty-wait-message', {duration: 0.2});
 }
 
+// Walk all the inputs in the document, disabling any that are related
+// to the action we're performing
+function disable_fields_for_actions (){
+    var actions = arguments[0];
+    for(var i = 0; i < actions.length; i++) {
+	var moniker = actions[i];
+	inputs = document.getElementsByTagName('input');
+	for(var j = 0; j < inputs.length; j++) {
+	    var input = inputs[j];
+	    if(input.id.indexOf(moniker) >= 0) {
+		input.disabled = true;
+	    }
+	}
+    }
+}
 
 
 Jifty.Autocompleter = Class.create();


More information about the Jifty-commit mailing list