Workaround Firefox and IE not showing file selection dialog

This commit is contained in:
Pierre-Olivier Latour
2014-11-07 11:42:36 +09:00
parent 15caa9cd20
commit bf2c9a170d
2 changed files with 12 additions and 1 deletions
@@ -65,7 +65,7 @@
<div id="alerts"></div> <div id="alerts"></div>
<div class="btn-toolbar"> <div class="btn-toolbar">
<button type="button" class="btn btn-primary fileinput-button"> <button type="button" class="btn btn-primary fileinput-button" id="upload-file">
<span class="glyphicon glyphicon-upload"></span> Upload Files&hellip; <span class="glyphicon glyphicon-upload"></span> Upload Files&hellip;
<input id="fileupload" type="file" name="files[]" multiple> <input id="fileupload" type="file" name="files[]" multiple>
</button> </button>
@@ -178,6 +178,17 @@ function _reload(path) {
$(document).ready(function() { $(document).ready(function() {
// Workaround Firefox and IE not showing file selection dialog when clicking on "upload-file" <button>
// Making it a <div> instead also works but then it the button doesn't work anymore with tab selection or accessibility
$("#upload-file").click(function(event) {
$("#fileupload").click();
});
// Prevent event bubbling when using workaround above
$("#fileupload").click(function(event) {
event.stopPropagation();
});
$("#fileupload").fileupload({ $("#fileupload").fileupload({
dropZone: $(document), dropZone: $(document),
pasteZone: null, pasteZone: null,