[英]How can I access ExtJS elements using `document.querySelector()`?
I'm attempting to integrate the http://www.dropzonejs.com/ file uploader into an existing ExtJS 3.4 application. 我正在尝试将http://www.dropzonejs.com/文件上传器集成到现有的ExtJS 3.4应用程序中。 I'm running into problems, as the elements created by ExtJS do not seem to be available using native document.
我遇到了问题,因为使用本机document.
似乎无法使用ExtJS创建的元素document.
methods, used by DropzoneJS. DropzoneJS使用的方法。
I want to render the upload panel inside a dynamically created ExtJS window: 我想在动态创建的ExtJS窗口中呈现上载面板:
App.DropzoneWindow = function(config) {
config = config || {};
Ext.applyIf(config, {
url: App.config.connectorUrl
,dropzone: null
,base_params: {}
});
OB.DropzoneWindow.superclass.constructor.call(this, config);
this.dropzone = this.initDropzoneJs();
};
Ext.extend(App.DropzoneWindow, App.Window, {
initDropzoneJs: function() {
var config = {
url: this.url
};
return new Dropzone('div#'+this.id, config);
}
});
Ext.reg('app-dropzone-window', App.DropzoneWindow);
Dropzone.js is throwing an error "Invalid dropzone element" immediately, as it's trying to access my target window element using document.querySelector()
. Dropzone.js尝试使用document.querySelector()
访问我的目标窗口元素时,立即抛出错误“无效的dropzone元素”。 Here are the lines in throwing the error in the source code: 以下是在源代码中引发错误的行:
https://github.com/enyo/dropzone/blob/master/downloads/dropzone.js#L636-L640 https://github.com/enyo/dropzone/blob/master/downloads/dropzone.js#L636-L640
Any ideas how I can achieve this without modifying the Dropzone.js source? 有什么想法可以在不修改Dropzone.js源代码的情况下实现这一目标吗?
I think the problem is that you are trying to access elements before panel is rendered, so that will never give you elements 我认为问题在于,您正在尝试在渲染面板之前访问元素,这样就永远不会给您元素
use afterrender event to initialize DropZone.js 使用afterrender事件初始化DropZone.js
App.DropzoneWindow = function(config) {
config = config || {};
Ext.applyIf(config, {
renderTo : Ext.getBody(),
listeners : {
afterrender : this.initDropzoneJs,
scope : this
}
});
OB.DropzoneWindow.superclass.constructor.call(this, config);
};
Ext.extend(App.DropzoneWindow, App.Window, {
initDropzoneJs: function() {
var config = {
url: this.url
};
return new Dropzone('div#'+this.id, config);
}
});
Ext.reg('app-dropzone-window', App.DropzoneWindow);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.