Dropzone.js で削除関数を作成しようとしています。そのためには、アップロードされたファイルの ID が必要です。
オブジェクトのプロパティを取得しようとしましたが、成功しませんでした。今、jQuery を使用して、それを持つスパンの値またはテキスト コンテンツを取得しようとしています。
これは構造のスクリーンショットです。私が試しているjQueryコードは次のとおりです。
var loooot = $(".dz-filename").parents('span').text();
より具体的には、番号 1_1477778745352 (タイムスタンプ) を取得しようとしています。
ドロップゾーンのコードは次のとおりです。
<script>
var listing_id = "1";
// these are the setting for the image upload
Dropzone.options.pud = {
acceptedFiles: ".jpeg,.jpg,.png,.gif",
uploadMultiple: false,
paramName: "file", // The name that will be used to transfer the file
maxFilesize: 1, // MB
addRemoveLinks: true,
maxFiles: 10,
renameFilename: function (filename) {return listing_id + '_' + new Date().getTime();},
init: function()
{
this.on("removedfile", function(file)
{
var loooot = $("span", ".dz-filename").html();
alert(loooot);
});
}
};
</script>