我有一个 PLUpload,正在 jQueryUI 模式对话框中启动。在对话框中启动后,PlUpload 的拖放操作仍然有效,但单击启动文件浏览器则不起作用。
下面代码的 JsFiddle。 JsFiddle 包括我的应用程序正在使用的 jQuery 和 jQuery UI 版本: http://jsfiddle.net/QqPLV/1/
HTML:
<a href="#" id="add-file-link">Open Uploader As Dialog</a>
<div id="AddFilePopup" title="Add A File">
<div id="drop-target">After opening in a dialog clicking here does nothing, but drag and drop in Chrome still works...</div>
<div id="plupload-nohtml5">No runtime found, your browser doesn't support HTML5 drag & drop upload.</div>
<div id="plupload-filelist"></div>
</div>
CSS:
#drop-target {
border: 3px dashed #CCC;
text-align: center;
color: #999;
font-size: 16px;
padding : 50px;
cursor: pointer;
}
#debug {
margin-top: 20px;
}
#plupload-debug {
border : 1px Solid #600;
padding : 5px;
margin : 5px;
}
Javascript:
$(function () {
$('#add-file-link').click(function () {
$('#AddFilePopup').dialog({
modal: true,
width: 600
});
uploader.refresh(); //this fixes IE10 not being able to click to add files
return false;
});
initPlUpload();
});
function initPlUpload() {
uploader = new plupload.Uploader({
runtimes: 'html5',
drop_element: 'drop-target',
browse_button: 'drop-target',
max_file_size: '4mb',
upload: "upload.php"
});
uploader.bind('Init', function (up, params) {
if (uploader.features.dragdrop) {
$('#plupload-nohtml5').hide();
};
});
uploader.bind('FilesAdded', function (up, files) {
for (var i in files) {
$('#plupload-filelist').append('<div id="' + files[i].id + '">- ' + files[i].name + ' - ' + files[i].id + ' (' + plupload.formatSize(files[i].size) + ')</div>');
}
});
uploader.init();
}
我添加了该行
uploader.refresh();
到点击处理程序,这修复了 IE10,但 Chrome 仍然拒绝合作。甚至输入 uploader.refresh();进入 Chrome 控制台并不能恢复上传者的浏览功能...
编辑:删除一些不需要重现问题并使其难以阅读的行。
最佳答案
我也有同样的问题,有一个解决方案。当您使用 HTML5 作为上传引擎时,就会发生这种情况,因此要解决这个问题,您需要添加样式:
.plupload{ z-index : 99999; }
或者如果您喜欢即时......
$("div.plupload").css({"z-index":99999});
这应该可以解决您的问题。
另一件事是您在创建窗口之前销毁了 uploader ,因此它不起作用。如果你想在对话框中执行pluploader,我建议你使用参数open ,因此当对话框初始化时,它会在其上运行 pluploader 的行为。
关于javascript - Jquery UI 对话框中的 PlUpload 无法单击添加文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16845991/