Comment #5 on issue 794 by Can not add screenshot

Note, this problem also prevents me from accessing "Update Diff"  
functionality, so it
seems to be consistent for all uses of formDlg (currently, only Update Diff  
Attach Screenshot).

The following very crude patch seems to work for me: if the  
'upload' flag is set, this turns the AJAX call into a standard form post.  
The real
fix is probably to use a jQuery/YUI upload widget and/or implement iframe  

Note that form.submit was never being activated before my change (the  
existing code
trapped the submit button to do AJAX and returned false, blocking real form
submission), so I removed the 'submit' trap to allow my hack to work.

Index: htdocs/media/rb/js/common.js
--- htdocs/media/rb/js/common.js        (revision 1666)
+++ htdocs/media/rb/js/common.js        (working copy)
@@ -170,10 +170,8 @@

          var form = $("<form/>")
              .attr("action", options.action)
-            .submit(function(e) {
-                send();
-                return false;
-            })
+            .attr("method", "POST") // ignored for non-uploads
+            .attr("enctype", "multipart/form-data") // ignored for  
@@ -235,8 +233,8 @@
                      $('<input type="button"/>')
                          .click(function() {
-                            send();
-                            return false;
+if(console) console.log("submitting from box", "this", this, "self",  
self, "form",
+                            return send(form);
@@ -248,15 +246,26 @@
           * Sends the form data to the server.
-        function send() {
+        function send(f) {
+if(console) console.log("in send", options);
+            if( options.upload && f ) {
+                var a = options.url || (SITE_ROOT + "api/json" +  
+                $(f).attr("action", a);
+if(console) console.log("submitting...", f);
+                f.submit(); // ugly: this will redirect the user to a JSON  
+                return true;
+            }
                  path: options.path,
                  buttons: $("input", self.modalBox("buttons")),
                  errorPrefix: "Saving the form failed due to a server  
                  success: function(rsp) {
+if(console) console.log("in send success", rsp);
+            return false;

I'll also note that I was blocked from uploading some valid JPEG files, but  
that is
probably a separate issue (to be filed once images can be uploaded).

You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:

You received this message because you are subscribed to the Google Groups 
"reviewboard-issues" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to