Javascript 如何使用“document.querySelector()”访问ExtJS元素?
我正在尝试将文件上传程序集成到现有的ExtJS 3.4应用程序中。我遇到了问题,因为ExtJS创建的元素似乎无法使用DropzoneJS使用的本机Javascript 如何使用“document.querySelector()”访问ExtJS元素?,javascript,extjs,domdocument,extjs3,dropzone.js,Javascript,Extjs,Domdocument,Extjs3,Dropzone.js,我正在尝试将文件上传程序集成到现有的ExtJS 3.4应用程序中。我遇到了问题,因为ExtJS创建的元素似乎无法使用DropzoneJS使用的本机document.方法 我想在动态创建的ExtJS窗口中呈现上载面板: App.DropzoneWindow = function(config) { config = config || {}; Ext.applyIf(config, { url: App.config.connectorUrl ,dr
document.
方法
我想在动态创建的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立即抛出错误“Invalid Dropzone element”,因为它试图使用document.querySelector()
访问我的目标窗口元素。以下是在源代码中抛出错误的代码行:
你知道我如何在不修改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);
掌心时刻!谢谢你的建议;工作完美:)