2014-10-13 116 views
1

我使用插件dropzonejs.com。 现在我写html文件的代码如何捕捉dropzonejs插件的事件

<form action="<?php print $this->link('task', 'upload'); ?>" id="pinupload" class="dropzone" style="width:450px;"> 
         </form> 

,它的工作完美英寸但我需要dropzone的catch事件:文件上传时,开始上传时确认。

我写了这个代码:

Dropzone.options.myDropzone = { 
    init: function() { 
     this.on("addedfile", function(file) { 

     // Capture the Dropzone instance as closure. 
     var _this = this; 

     // Listen to the click event 
     removeButton.addEventListener("click", function(e) { 
      // Make sure the button click doesn't submit the form: 
      e.preventDefault(); 
      e.stopPropagation(); 

      // Remove the file preview. 
      _this.removeFile(file); 
      // If you want to the delete the file on the server as well, 
      // you can do the AJAX request here. 
     }); 
     }); 
    } 
    }; 

但与此代码,我不能赶上事件。为什么?

回答

1

对不起,它的代码工作,只是我不注意。表单ID应该有“myDropzone”。