我正在尝试使用jsfiddle示例jsfiddle-plupload
进行plupload工作但这对我不起作用,如果在下面跳过块的状态更改事件是代码
function validClasses()
{
datas=[];
$('#uids li').each(function() {
var data = {
className: $(this).attr("id")
};
datas.push(data);
});
if(datas.length>0)
{
return true;
}else{
alert('error');
return false;
}
}
var uploadInitialized = false;
function plupload(){
var uploader = $("#uploader").pluploadQueue({
// General settings
runtimes: 'html5,html4',
url: 'fileUpload.htm',
max_file_size: '200mb',
chunk_size: '1mb',
unique_names: true,
multiple_queues: true,
multipart_params: {
"name": $("#name").val()
},
// Specify what files to browse for
filters: [
{
title: "Image files",
extensions: "jpg,gif,png,eps,jpeg,pdf,tiff,tif"},
{
title: "Zip files",
extensions: "zip"}
],
init: {
StateChanged: function(up) {
if (!uploadInitialized && up.state == plupload.STARTED) {
if (!validClasses()) {
up.stop();
} else {
uploadInitialized = true;
}
}
},
BeforeUpload: function(up, file) {
up.settings.multipart_params = {'name': $('#name').val()}
}
}
});
}
请注意,在jsfiddle示例中,上传刚刚停止,即我可以上传而无需再次添加文件。在我这边,开始上传按钮消失,文件在列表中,但按钮消失。我正在获取上传状态代替按钮,我希望按钮也在那里,如果上传也停止。我的意思是在StateChanged我直接写了up.stop(),这也是行不通的。有人请帮忙。感谢。