lup*_*ant 5 javascript dropzone.js
我需要以编程方式更改maxFiles选项.这是我的初始:
Dropzone.options.dropzone = {
paramName: "files",
params:true,
url: "/upload.php",
autoProcessQueue: true,
uploadMultiple: true,
parallelUploads: 10,
maxFiles: fileleft,
previewsContainer: ".dropzone",
clickable: true,
addRemoveLinks: false,
acceptedFiles: '.jpg,.pdf,.png,.bmp',
dictInvalidFileType: 'Unsupported.',
accept: function(file, done) {
done();
},
init: function() {
var myDropzone = this;
this.on("successmultiple", function(files, response) {
ins.pop_gallery(id);
this.removeAllFiles();
this.on("maxfilesexceeded", function(file){
this.removeFile(file);
});
this.on("sending", function(file, xhr, formData) {
formData.append("custom", id );
});
}
}
Run Code Online (Sandbox Code Playgroud)
一切正常,但我需要稍后更改maxFiles选项值.
我试过这个:
Dropzone.options.dropzone.maxFiles = fileleft;
Run Code Online (Sandbox Code Playgroud)
还有这个:
myDropzone.maxFiles = fileleft;
Run Code Online (Sandbox Code Playgroud)
但尽管有这个代码
alert(Dropzone.options.dropzone.maxFiles);
Run Code Online (Sandbox Code Playgroud)
给我正确答案,maxFiles上传限制实际上仍然没有变化.
任何想法?
谢谢.
首先,谢谢你的重播.我发现重新初始化插件有一些问题,最后我认为我的错误是在init中:
init: function() {
var myDropzone = this;
Run Code Online (Sandbox Code Playgroud)
重新声明var我在进一步的代码中失去了可见性.
如此改变
init: function() {
myDropzone = this;
Run Code Online (Sandbox Code Playgroud)
(没有var)
myDropzone变得易于访问所以声明
myDropzone.options.maxFiles = fileleft;
Run Code Online (Sandbox Code Playgroud)
现在正在努力.
非常感谢.
| 归档时间: |
|
| 查看次数: |
4468 次 |
| 最近记录: |