Ran*_*ily 5 javascript ajax jquery
我使用dropzone.js并使用ajax加载它.
我的菜单ID ="#menu"上传文件应出现在"#div1"中
回调函数不起作用.我用alert("test")取代了Dropzone.discover;
(document).ready(function() {
$("#menu").click(function(){
$("#div1").load("upload.php",null, function(){
Dropzone.discover();
});
Run Code Online (Sandbox Code Playgroud)
注意:我尝试了下面的代码,但它没有用.
$("#div1").load("upload.php", function(){
Dropzone.discover();
});
Run Code Online (Sandbox Code Playgroud)
小智 2
您应该在 #dive 上定义 dropzone 并将事件添加到 dropzone 的 init 函数中以更改与每个 #menu 相关的选项。这是最好的方法。
前面的例子:
var myDropzone = new Dropzone("#div1",{
url: '/test.php',
acceptedFiles: "image/*",
addRemoveLinks: true,
removedfile: function(file) {
$.get('remove.php',function(data){
var _ref;
return (_ref = file.previewElement) != null ? _ref.parentNode.removeChild(file.previewElement) : void 0;
});
},
init: function() {
var thisDropzone = this;
$('body').on('click','a.menu',function(event){
href = $(this).attr('href');
thisDropzone.options.url = href;
});
$("body").on('click','#btnRemoveAll',function () {
thisDropzone.removeAllFiles();
}
);
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9439 次 |
| 最近记录: |