Fixing bug in issue file upload for chrome. The onchange event (DOM) being available during a .clone() is causing recursive calls to addInputFiles(this), causing multiple uploads during normal browsing and crashing inspect view. This change removes the onchange attribute for the duration of the clone, and restores it when it is complete. diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js index ab9f89a..f5bbeb0 100644 --- a/public/javascripts/attachments.js +++ b/public/javascripts/attachments.js @@ -115,7 +115,9 @@ function uploadBlob(blob, uploadUrl, attachmentId, options) { } function addInputFiles(inputEl) { - var clearedFileInput = $(inputEl).clone().val(''); + var onchange = $(inputEl).attr("onchange"); + var clearedFileInput = $(inputEl).attr("onchange", null).clone().val(''); + clearedFileInput.attr("onchange", onchange); if (inputEl.files) { // upload files using ajax