admin管理员组文章数量:1406308
Based on Dropozone.js FAQ I have tried to display a message on successful upload.
Code from the header
looks like:
<script>
$(document).ready(function() {
Dropzone.options.myDropzone = {
init: function() {
this.on("success", function(file, responseText) {
var responseText = "TaDa!";
file.previewTemplate.appendChild(document.createTextNode(responseText));
});
}
};
)};
</script>
And code from the html
section:
<form action="/file-upload" class="dropzone" id="my-dropzone"></form>
Drag and drop upload works fine but I'm not getting desired message on success
.
Based on Dropozone.js FAQ I have tried to display a message on successful upload.
Code from the header
looks like:
<script>
$(document).ready(function() {
Dropzone.options.myDropzone = {
init: function() {
this.on("success", function(file, responseText) {
var responseText = "TaDa!";
file.previewTemplate.appendChild(document.createTextNode(responseText));
});
}
};
)};
</script>
And code from the html
section:
<form action="/file-upload" class="dropzone" id="my-dropzone"></form>
Drag and drop upload works fine but I'm not getting desired message on success
.
2 Answers
Reset to default 8This is because dropzone initializes before the options are set, to avoid this just place the dropzone options outside the ready
function.
<script>
Dropzone.options.myDropzone = {
init: function() {
this.on("success", function(file, responseText) {
var responseText = "TaDa!";
file.previewTemplate.appendChild(document.createTextNode(responseText));
});
}
};
$(document).ready(function() {
// Your other javascript
)};
</script>
I had this problem too and after trying the solution @wallek876 provided I was still unable to set options for the #Media_Dropzone
object. finally I've found that Dropzone is unable to find elements with ID's in which contain underscores!! so basically renaming the element from #Media_Dropzone
to #MediaDropzone
and of-course implementing the accepted answer here solved my problem.
本文标签: javascriptDropzonejs optionscannot get them to workStack Overflow
版权声明:本文标题:javascript - Dropzone.js options - cannot get them to work - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745006885a2637316.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论