问题描述
我找不到有关创建DojoX中/表格/上传编程任何文档。我试了一下我自己,但它看起来像该插件登记机构以某种方式打破。
I can't find any docs about creating dojox/form/Uploader programmatically. I tried it by myself, but it looks like that plugin registering mechanism is somehow broken.
require([
"dojo/dom-construct",
"dijit/form/Button",
"dojox/form/Uploader",
"dojox/form/uploader/FileList",
"dojox/form/uploader/plugins/IFrame",
"dojo/domReady!"
], function(domConstruct, Button, Uploader, UploaderFileList) {
var form = domConstruct.create('form', {
method: 'post',
enctype: 'multipart/form-data',
class: 'Uploader'
}, document.body);
var up = new Uploader({
label: 'Pick files',
multiple: true,
url: '/echo/json/'
}).placeAt(form);
var list = new UploaderFileList({
uploader: up
}).placeAt(form);
var btn = new Button({
type: 'submit',
label: 'upload',
onClick: function() {
up.upload();
}
}).placeAt(form);
btn.startup();
up.startup();
list.startup();
});
实例上的jsfiddle 这里。
据我了解,源$ C $的DojoX中/表格/上传和DojoX中/表格/上传/插件/ IFrame的C,这个插件是通过dojox.form.addUploaderPlugin功能,使用它redeclares上传器窗口小部件类注册自我和插入插件为predecessors。但关键的方法上传上传小部件将无法得到HTML5的插件(这是使用iframe插件自动包含)覆盖。
As far as I understand, source code of dojox/form/Uploader and dojox/form/uploader/plugins/IFrame, the plugin is registered via dojox.form.addUploaderPlugin function, which redeclares the Uploader widget class using self and plugged plugins as its predecessors. But the key method "upload" of Uploader widget never gets overridden by HTML5 plugin (which is included automatically with Iframe plugin).
这是错误吗?还是我做错了什么?
Is this bug? Or I am doing something wrong?
感谢您的帮助!
推荐答案
在短;使用,而不是拉变新dojox.form.Uploader,否则扩展插件不适用。
In short; use new dojox.form.Uploader instead of the pulled in variable, otherwise the plugin extending does not apply.
原因是,你会看到程序员做以下的addUploaderPlugin:
Reason being, you would see programmer doing following in the addUploaderPlugin:
dojox.form.UploaderOrg = dojox.form.Uploader;
var extensions = [dojox.form.UploaderOrg];
dojox.form.addUploaderPlugin = function(plug){
extensions.push(plug);
declare("dojox.form.Uploader", extensions, {});
}
这是AMD加载器返回的类,将百达是dojox.form.UploaderOrg,不知道该扩展插件。
The class that AMD loader returns is and will allways be dojox.form.UploaderOrg and does not know about the extended plugins.
更改为以下内容:
var up = new dojox.form.Uploader({
label: 'Pick files',
multiple: true,
url: '/echo/json/'
}).placeAt(form);
和确保你有不可以设置 djConfig.publishRequireResult = FALSE
这篇关于编程DojoX中上传 - 阿贾克斯上传不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!