She*_*don 55 javascript jquery
我正在使用dropzone.js上传文件.但是,我在更改默认文本时遇到了困难.
我试过实例化dropzone类:
$(document).ready(function(){
$(".foo").dropzone({ dictDefaultMessage: "hello" });
});
Run Code Online (Sandbox Code Playgroud)
有了这个标记:
<div class="span4">
<form action="http://localhost/post" method="post" accept-charset="utf-8" id="drop3" class="foo" enctype="multipart/form-data"> </form>
</div>
<div class="span4">
<form action="http://localhost/post" method="post" accept-charset="utf-8" id="drop4" class="foo" enctype="multipart/form-data"> </form>
</div>
Run Code Online (Sandbox Code Playgroud)
这当然使我能够上传文件,但默认文本是空白的.
我测试了以下内容:
$(".foo").dropzone();
Run Code Online (Sandbox Code Playgroud)
我似乎得到了相同的结果 - 没有默认文本.那么..如何更改默认文本?
spe*_*ley 141
在dropzone表单中添加一个元素,如下所示:
<div class="dz-message" data-dz-message><span>Your Custom Message</span></div>
Run Code Online (Sandbox Code Playgroud)
Ser*_*ral 47
您可以使用以下命令更改所有默认消息:
Dropzone.prototype.defaultOptions.dictDefaultMessage = "Drop files here to upload";
Dropzone.prototype.defaultOptions.dictFallbackMessage = "Your browser does not support drag'n'drop file uploads.";
Dropzone.prototype.defaultOptions.dictFallbackText = "Please use the fallback form below to upload your files like in the olden days.";
Dropzone.prototype.defaultOptions.dictFileTooBig = "File is too big ({{filesize}}MiB). Max filesize: {{maxFilesize}}MiB.";
Dropzone.prototype.defaultOptions.dictInvalidFileType = "You can't upload files of this type.";
Dropzone.prototype.defaultOptions.dictResponseError = "Server responded with {{statusCode}} code.";
Dropzone.prototype.defaultOptions.dictCancelUpload = "Cancel upload";
Dropzone.prototype.defaultOptions.dictCancelUploadConfirmation = "Are you sure you want to cancel this upload?";
Dropzone.prototype.defaultOptions.dictRemoveFile = "Remove file";
Dropzone.prototype.defaultOptions.dictMaxFilesExceeded = "You can not upload any more files.";
Run Code Online (Sandbox Code Playgroud)
Fir*_*rze 30
创建dropzone时,您可以像这样设置默认消息.
var dropzone = new Dropzone("form.dropzone", {
dictDefaultMessage: "Put your custom message here"
});
Run Code Online (Sandbox Code Playgroud)
然后
$('div.dz-default.dz-message > span').show(); // Show message span
$('div.dz-default.dz-message').css({'opacity':1, 'background-image': 'none'});
Run Code Online (Sandbox Code Playgroud)
首先在表单中添加一个id,比如说mydz,然后添加这个js:
Dropzone.options.mydz = {
dictDefaultMessage: "your custom message"
};
Run Code Online (Sandbox Code Playgroud)
整个页面(本例中为index.php):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="dropzone.js"></script>
<link rel="stylesheet" type="text/css" href="./dropzone.css">
<title></title>
</head>
<body>
<form action="upload.php" class="dropzone" id="mydz"></form>
<script type="text/javascript">
Dropzone.options.mydz = {
dictDefaultMessage: "Put your custom message here"
};
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
小智 7
这个文本在dropzone的默认配置中,你可以像这样覆盖:
Dropzone.prototype.defaultOptions.dictDefaultMessage = "Your text";
Run Code Online (Sandbox Code Playgroud)
我摆弄了几个小时。
出于某种原因,需要完成以下 3 件事:
Dropzone.autoDiscover = false;
初始化:
var myDropzone = new Dropzone("#id-upload-dropzone", {
url: "/home/Upload",
dictDefaultMessage: 'Drop image here (or click) to capture/upload'
});
Run Code Online (Sandbox Code Playgroud)
一旦我按顺序排列了所有 3 个,dictDefaultMessage 选项就起作用了。
小智 5
myDropzonePhotos = new Dropzone('#dropzone-test',
{
url : 'upload_usuario.php?id_usuario=' + id_usuario,
maxFiles : 1,
thumbnailWidth : 1200,
thumbnailHeight : 300,
dictDefaultMessage : 'Change the text here!',
init: function()
{
....
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
69231 次 |
| 最近记录: |