当我用ajax调用它时,DropZone插件不起作用

时间:2015-10-06 05:16:06

标签: javascript jquery ajax dropzone.js

当我用ajax调用它时,插件不起作用。

Dropzone插件:http://www.dropzonejs.com/

main.html中

<html>
<head>
  <link rel="stylesheet" href="/vendor/dropzone/dist/min/basic.min.css">
  <link rel="stylesheet" href="/vendor/dropzone/dist/min/dropzone.min.css">
</head>
<body>


  <div class="ajaxBlock">

  </div>

<script src="/vendor/jquery/dist/jquery.js"></script>
<script src="/vendor/dropzone/dist/min/dropzone.min.js"></script>
<script>
  $(document).ready(function(){
    $.post('/calling-page.html', function(result){
      $('.ajaxBlock').html(result);
    });
  });
</script>
</body>
</html>

主叫page.html中

<form action="/file-upload" class="dropzone" id="my-awesome-dropzone"></form>

1 个答案:

答案 0 :(得分:0)

尝试以编程方式初始化它,如下所示:

当您使用<form>元素时;然后在启动它时无需指定url:选项:

$(document).ready(function(){
    $.post('/calling-page.html', function(result){
      $('.ajaxBlock').html(result);
      var myDropzone = new Dropzone("#my-awesome-dropzone");
    });
  });

OR

$(document).ready(function(){
     $.post('/calling-page.html', function(result){
          $('.ajaxBlock').html(result);
          $("#my-awesome-dropzone").dropzone();
     });
});