2013-10-11 5 views
1

http://www.dropzonejs.com/ 파일 업 로더를 기존 ExtJS 3.4 응용 프로그램에 통합하려고합니다. ExtJS에서 만든 요소가 DropzoneJS에서 사용하는 기본 document. 메서드를 사용하여 사용할 수없는 것 같아 문제가 발생합니다.`document.querySelector()`를 사용하여 ExtJS 요소에 어떻게 액세스 할 수 있습니까?

나는 동적으로 생성 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 오류 "잘못된 DROPZONE 요소"를 던지고있다

즉시, document.querySelector()를 사용하여 내 목표 창 요소에 액세스하려고으로 . 다음은 소스 코드에서 오류를 던지는 라인은 다음과 같습니다

https://github.com/enyo/dropzone/blob/master/downloads/dropzone.js#L636-L640

나는 Dropzone.js 소스를 수정하지 않고이를 달성 할 수있는 방법 어떤 아이디어가?

답변

2

나는 문제가 당신에게 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); 
+0

마른 세수 모멘트를 초기화하는

사용 afterrender 이벤트를 요소를 제공하지 않습니다 있도록, 패널이 렌더링되기 전에 요소에 액세스하려고하는 것을 생각! 제안 해 주셔서 감사합니다. 완벽하게 작동합니다 :) – okyanet