简体   繁体   中英

How add custom wrapper div around image preview in Dropzone.js?

I am using Dropzone.js for image uploads with drag & drop functionlity. Now my question is how to add custom Wrapper/Coantainer DIV around image upload images.

在此处输入图片说明

Just like this:

<html lang="en">
<head>
<body>
    <div id="some-dropzone" class="dropzone dz-clickable dz-square dz-started">
        <div class="dz-default dz-message" data-dz-message="">
        <div id="my-custom-div"> <! -- My custom wrapper div around preview div -->
            <div class="dz-preview dz-processing dz-image-preview dz-success">
            <div class="dz-preview dz-processing dz-success dz-image-preview">
            <div class="dz-preview dz-processing dz-success dz-image-preview">
            <div class="dz-preview dz-processing dz-success dz-image-preview">
            <div class="dz-preview dz-processing dz-success dz-image-preview">
            <div class="dz-preview dz-processing dz-success dz-image-preview">
            <div class="dz-preview dz-processing dz-success dz-image-preview">
            <div class="dz-preview dz-processing dz-success dz-image-preview">
        </div>
    </div>
</body>
</html>

I want display all image with scrollbar in single row. So do you have any idea how to do that in Dropzone.js or any other way.

在此处输入图片说明

Thanks.

Updated: http://jsfiddle.net/lotusgodkk/1cy803ar/4/

JS:

$('#some-dropzone').append("<div id='my-custom-div'></div>");
$('#some-dropzone #my-custom-div').append($('#some-dropzone .dz-preview'));

Try following solution with dropzone initialize code.

this.on("success", function(file, serverFileName) {

     if (!$('#preview-wrapper').length){
         $(".dz-preview").wrapAll("<div id='preview-wrapper'></div>");
     }

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM