FineUploader-确认后删除文件(自定义确认窗口)

时间:2019-05-11 12:57:36

标签: javascript html

我正在使用FineUploader上传/删除文件。我创建了自己的确认窗口,但是在确认之前文件已被删除。确认后是否可以防止删除和删除文件?

$('#fine-uploader-manual-trigger').fineUploader({
  deleteFile: {
    enabled: true,
    forceConfirm: true,
    customHeaders: {
      'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
    },
    endpoint: '/odstranitObrazek'
  },
  showConfirm: function() {
    $('#confirmModal').modal('show')
  },
  callbacks: {
    onSubmitDelete: function(id) {
      $('#deletePhoto').on('click', function() {
        $('#fine-uploader-manual-trigger').fineUploader('deleteFile', id);
      });

    }
  }
});
<div id="confirmModal" class="modal fade">
  <div class="modal-dialog modal-confirm">
    <div class="modal-content">
      <div class="modal-header">
        <div class="icon-box">
          <i class="fa fa-times material-icons " aria-hidden="true"></i>

        </div>
        <h4 class="modal-title">Upozornění</h4>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      </div>
      <div class="modal-body">

      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-info" data-dismiss="modal">Zrušit</button>
        <button id="deletePhoto" type="button" class="btn btn-info" data-dismiss="modal">Odstranit</button>
      </div>
    </div>
  </div>
</div>

更新: 我能够使用qq.Promise来做到这一点。问题是我只能删除1个文件。当我尝试删除第二个时,出现此错误:TypeError: element is null

showConfirm:function(){
    let promise = new qq.Promise();
    $('#confirmModal').modal('show');
    $(document).on('click','#deletePhoto',function(){
        promise.success('Confirm');
    });

    return promise;
},

0 个答案:

没有答案