Skip to content

Commit a7b0410

Browse files
committed
Fix Iframe Transport form submit for Safari 13.
Fixes blueimp#3633
1 parent 8f944af commit a7b0410

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

js/jquery.iframe-transport.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,19 +153,25 @@
153153
// Remove the HTML5 form attribute from the input(s):
154154
options.fileInput.removeAttr('form');
155155
}
156-
form.submit();
157-
// Insert the file input fields at their original location
158-
// by replacing the clones with the originals:
159-
if (fileInputClones && fileInputClones.length) {
160-
options.fileInput.each(function (index, input) {
161-
var clone = $(fileInputClones[index]);
162-
// Restore the original name and form properties:
163-
$(input)
164-
.prop('name', clone.prop('name'))
165-
.attr('form', clone.attr('form'));
166-
clone.replaceWith(input);
167-
});
168-
}
156+
window.setTimeout(function () {
157+
// Submitting the form in a setTimeout call fixes an issue with
158+
// Safari 13 not triggering the iframe load event after resetting
159+
// the load event handler, see also:
160+
// https://github.com/blueimp/jQuery-File-Upload/issues/3633
161+
form.submit();
162+
// Insert the file input fields at their original location
163+
// by replacing the clones with the originals:
164+
if (fileInputClones && fileInputClones.length) {
165+
options.fileInput.each(function (index, input) {
166+
var clone = $(fileInputClones[index]);
167+
// Restore the original name and form properties:
168+
$(input)
169+
.prop('name', clone.prop('name'))
170+
.attr('form', clone.attr('form'));
171+
clone.replaceWith(input);
172+
});
173+
}
174+
}, 0);
169175
});
170176
form.append(iframe).appendTo(document.body);
171177
},

0 commit comments

Comments
 (0)