最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to change the default text in dropzone.js? - Stack Overflow

programmeradmin2浏览0评论

I'm having trouble changing the default text of my dropzone uploader. Despite the fact that I've initialized it like this, it's still rendering the default text:

Dropzone.options.imgUpload = {
    paramName: "file", // Must match the name of the HttpPostedFileBase argument that the Upload action expects.
    dictDefaultMessage: "Drag your image here",
    acceptedFiles: "image/*" // Accept images only
};

Also tried changing the dictDefaultMessage set in dropzone.js, but with no luck :( By the way; am I supposed to use both or remove one of them?

Any suggestions?

I'm having trouble changing the default text of my dropzone uploader. Despite the fact that I've initialized it like this, it's still rendering the default text:

Dropzone.options.imgUpload = {
    paramName: "file", // Must match the name of the HttpPostedFileBase argument that the Upload action expects.
    dictDefaultMessage: "Drag your image here",
    acceptedFiles: "image/*" // Accept images only
};

Also tried changing the dictDefaultMessage set in dropzone.js, but with no luck :( By the way; am I supposed to use both or remove one of them?

Any suggestions?

Share Improve this question edited Nov 24, 2016 at 17:12 Rishabh 3,8524 gold badges48 silver badges75 bronze badges asked Nov 29, 2013 at 14:24 Nicklas Pouey-WingerNicklas Pouey-Winger 3,0237 gold badges46 silver badges76 bronze badges
Add a comment  | 

4 Answers 4

Reset to default 8

Solved this by including the basic.css file alone. This does not render the sprites and you have full control of styling inside the dropzone (It just gives jo a basic skeleton to improve upon). When doing this, dictDefaultMessage is displayed.

This is based on the documentation of dropzone.js (enter link description here)

(without styles) http://jsfiddle.net/44pnR/1/

HTML

<form action="/file-upload"
      class="dropzone"
      id="img-upload"></form>

JS

/*"imgUpload" is the camelized version of the HTML element's ID*/
Dropzone.options.imgUpload  = {
    paramName: "file", // Must match the name of the HttpPostedFileBase argument that the Upload action expects.
    dictDefaultMessage: "custom message",
    acceptedFiles: "image/*" // Accept images only
};

The only thing that worked for me is to add:

<div class="dz-message" data-dz-message><span>Drag your image here!</span></div>

into my HTML file.

Adding anything with class as "dz-message" will replace the original text.

发布评论

评论列表(0)

  1. 暂无评论