代码之家  ›  专栏  ›  技术社区  ›  N6151H

停止生成预览?

  •  0
  • N6151H  · 技术社区  · 6 年前

    alert

    accept 通过调用提供的 done 具有非空参数的函数。例如。

    done("You need to enter a UPC code for this image.");
    return false;
    

    但是,仍然会创建预览,其中 error 覆盖。

    我尝试了几种方法,包括抓住 drop 没有成功的事件。即使我取消了事件(包括任何进一步的下游处理),它仍然希望进行预览。

    1 回复  |  直到 6 年前
        1
  •  0
  •   N6151H    6 年前

    removeFile accept 处理程序。

    所以,我的 处理程序如下所示:

    accept: function(file) {
      if (/* condition not met */) {
        alert("You haven't met the condition. No upload for you!");
        deleteOnServer = false;
        this.removeFile(file);
        deleteOnServer = true;
        return false;
      }
    
      /* otherwise, do normal "accept" processing. */
    

    在我的Dropzone中注册“removedFile”事件处理程序 init

    init:  function() {
      this.on("removedFile", function(file) {
        if (!deleteOnServer) {
            return false;
        }
    
        /* otherwise, send $.ajax(DELETE) request to server */
           :
      }