在JQuery FileUpload中返回删除成功 [英] Return success on delete in JQuery FileUpload
问题描述
我使用 blueimp的jquery文件上传插件。为了添加文件,有许多不同的回调。例如:
$ b $ pre $ $('#fileupload')。bind('fileuploaddone',function(e,data){/ * ... * /})
我想绑定一个回调,告诉我一个文件已成功删除,但我已经搜索了文档,找不到像这样的任何东西。任何人有一个想法,我怎么可以做到这一点?
更新:
我应该说,上述代码只返回UPLOADING文件。没有事件返回删除文件。这是我想尝试和实现bluimp的源代码。
回调的源代码在这里 https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery。 fileupload-ui.js
总结前面的评论,回调函数是处理通过事件 fileuploaddone
从服务器接收的数据。因此,您将拥有这样的代码:
$ $ p $ $('#fileupload')。bind('fileuploaddone',callbackfunc);
//您的回调函数
函数callbackfunc(e,data){
/ *您的代码,如:if(data.kind ===error)alert data.message); * /
}
但是您可以通过匿名函数缩短它:
$ b $ $ $ $ $''$ file $'$'''fileupload')。bind('fileuploaddone',function(e,data){/ *你的代码,如:if data.kind ===error)alert(data.message); * /})
$ b
编辑
对于删除,回调可以用事件 fileuploaddestroy
(见本页: BlueImp选项 )。
I am using blueimp's Jquery file upload plugin. For adding files, there are a host of different callbacks. For example:
$('#fileupload').bind('fileuploaddone', function (e, data) {/* ... */})
I would like to bind to a callback that tells me if a file has been deleted successfully, but I have searched the documentation and can't find anything that looks like it does this. Anyone have an idea how I could do this?
Update: I should say that the above code only returns for UPLOADING a file. No event is returned for deleting a file. This is what I want to try and implement into bluimp's source code.
Source code for callbacks is here https://github.com/blueimp/jQuery-File-Upload/blob/master/js/jquery.fileupload-ui.js
To summarize the previous comments, the callback function is the function that will handle the data received from the server via the event fileuploaddone
. Thus, you will have such code :
$('#fileupload').bind('fileuploaddone', callbackfunc);
// Your callback function
function callbackfunc(e, data) {
/* your code, like : if (data.kind === "error") alert(data.message); */
}
But you can shorten it via an anonymous function :
$('#fileupload').bind('fileuploaddone', function (e, data) {/* your code, like : if (data.kind === "error") alert(data.message); */})
EDIT
For deletion, the callback can be bound with event fileuploaddestroy
(see this page : BlueImp options).
这篇关于在JQuery FileUpload中返回删除成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!