Dynamically add dropzone.js div element to the form

Jaspal

I have to use multiple dropzone areas to upload images. I have used the jQuery append() function to dynamically create the div.

The problem is that the dynamically created dropzone is not initialized and therefore not working.

Jaspal

Here is the script i have used to do the same. I have changed the dynamically created input type text's name field by using the querySelector. The querySelector returns the reference of the elements which have custom attribute i have used data-tagline.

Dropzone.options.myDropzone = {
	            init: function() {
    	              this.on("addedfile", function(file) {
						  _ref = file.previewTemplate.querySelector('[data-tagline]');
						  _ref.name = "This is my New name attribute of element";
					  })
				},
				previewTemplate:"<div class=\"dz-preview dz-file-preview\">\n  "+
								"<div class=\"dz-details\">\n  "+
									"<div class=\"dz-filename\"><span data-dz-name></span></div>\n    "+
									"<div class=\"dz-size\" data-dz-size></div>\n    "+
									"<img data-dz-thumbnail class=\"img-responsive img-thumbnail\" />\n  "+
									"<input type=\"text\" data-tagline />"+
								"</div>\n  "+
								"<div class=\"dz-progress\">"+
									"<span class=\"dz-upload\" data-dz-uploadprogress></span>"+
								"</div>\n  "+
								"<div class=\"dz-success-mark\"><span>✔</span>"+
								"</div>\n  "+
								"<div class=\"dz-error-mark\"><span>✘</span>"+
								"</div>\n  "+
								"<div class=\"dz-error-message\"><span data-dz-errormessage></span>"+
								"</div>\n"+
							"</div>",
};
<div id="my-dropzone" class="dropzone" action="upload.php"></div>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Add ID to the preview div in Dropzone.js

From Dev

add maxfiles dynamically to dropzone

From Dev

Form button add dynamically in JS

From Dev

Dynamically add element in JS to XUL

From Dev

Create div element and dynamically add child elements on it

From Dev

check if span element exists and then add div dynamically

From Dev

How to add canvas to div element dynamically?

From Dev

javascript how to add element dynamically to form tag using button

From Dev

Add a div element dynamically in ng-repeat angularjs

From Dev

How to make only the Dropzone.js Previews Div clickable and not the whole form

From Dev

Laravel and dropzone using div and another form inputs

From Dev

Dropzone.js - nothing happens when click dropzone element

From Dev

JS/JQuery: Dynamically add "pattern" and "title" attribute to form input

From Dev

JS/JQuery: Dynamically add "pattern" and "title" attribute to form input

From Dev

Dynamically add element to layout

From Dev

JAXB add element dynamically

From Dev

Dynamically add/remove element

From Dev

How to add mouseenter event for dynamically added element with native JS

From Dev

How to dynamically add element with tabs in the list. Angular js

From Dev

react.js - how to add element on success in dynamically generated button?

From Dev

How to disable clickable the form with Dropzone.js?

From Dev

dropzone.js form submit not sending file

From Dev

dropzone.js is giving error "Invalid dropzone element" on page without a dropzone

From Dev

javascript - Remove form element dynamically

From Dev

Deleting uploaded files form Dropzone.js form

From Dev

Dynamically add a placeholder to a form field

From Dev

Dynamically add form fields in MeteorJS

From Dev

Django - Add field to form dynamically

From Dev

Dynamically add textareas into form in meteor

Related Related

  1. 1

    Add ID to the preview div in Dropzone.js

  2. 2

    add maxfiles dynamically to dropzone

  3. 3

    Form button add dynamically in JS

  4. 4

    Dynamically add element in JS to XUL

  5. 5

    Create div element and dynamically add child elements on it

  6. 6

    check if span element exists and then add div dynamically

  7. 7

    How to add canvas to div element dynamically?

  8. 8

    javascript how to add element dynamically to form tag using button

  9. 9

    Add a div element dynamically in ng-repeat angularjs

  10. 10

    How to make only the Dropzone.js Previews Div clickable and not the whole form

  11. 11

    Laravel and dropzone using div and another form inputs

  12. 12

    Dropzone.js - nothing happens when click dropzone element

  13. 13

    JS/JQuery: Dynamically add "pattern" and "title" attribute to form input

  14. 14

    JS/JQuery: Dynamically add "pattern" and "title" attribute to form input

  15. 15

    Dynamically add element to layout

  16. 16

    JAXB add element dynamically

  17. 17

    Dynamically add/remove element

  18. 18

    How to add mouseenter event for dynamically added element with native JS

  19. 19

    How to dynamically add element with tabs in the list. Angular js

  20. 20

    react.js - how to add element on success in dynamically generated button?

  21. 21

    How to disable clickable the form with Dropzone.js?

  22. 22

    dropzone.js form submit not sending file

  23. 23

    dropzone.js is giving error "Invalid dropzone element" on page without a dropzone

  24. 24

    javascript - Remove form element dynamically

  25. 25

    Deleting uploaded files form Dropzone.js form

  26. 26

    Dynamically add a placeholder to a form field

  27. 27

    Dynamically add form fields in MeteorJS

  28. 28

    Django - Add field to form dynamically

  29. 29

    Dynamically add textareas into form in meteor

HotTag

Archive