javascript dropzone.js 以编程方式不起作用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25152639/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 04:03:19  来源:igfitidea点击:

dropzone.js programmatically doesn't work

javascriptjquerydropzone.js

提问by Jo?o Manolo

I am trying create drop zones programmatically, but it doesn't work.

我正在尝试以编程方式创建拖放区,但它不起作用。

HTML Code:

HTML代码:

<div class="content-wrap">
   <div class="row">
      <script type="text/javascript">
         $(function() {
            $("div#myDropZone").dropzone({
                url : "/file-upload"
            });
         });
      </script>
      <div class="col-sm-12">
         <div class="nest" id="DropZoneClose">
            <div class="title-alt">
               <h6>DropZone</h6>
            </div>
            <div class="body-nest" id="DropZone">
               <div id="myDropZone" >
               </div>
               <button style="margin-top: 10px;" class="btn btn-info"
                  id="submit-all">Submit all files</button>
            </div>
         </div>
      </div>
   </div>
</div>

The drop zone in <div id="myDropZone">not appers!

<div id="myDropZone">不在的拖放区!

best regards :)

最好的祝福 :)

回答by go-oleg

You need to give your #myDropZonediv some width and height so that it takes up space. Heres a jsfiddle.

你需要给你的#myDropZonediv 一些宽度和高度,以便它占用空间。这是一个jsfiddle

Alternatively, you can add the dropzoneclass to your div to get the default styling that you see in the demos. Heres the jsfiddlefor that.

或者,您可以将该dropzone类添加到您的 div 中以获得您在演示中看到的默认样式。继承人的jsfiddle了点。

回答by Ayesh Shaminda

Add class dropzoneto the divelement which holds your drop zone. Hope that you have added the dropzonestylesheet to your page.

将类添加dropzonediv包含您的拖放区的元素。希望您已将dropzone样式表添加到您的页面。