Upload multiple files jquery. Multifile to clear the file list
When uploading multiple files, many people will use the jquery. Multifile plug-in. This plug-in is very useful. View my results.
You can delete an object separately. But I don't know if you have considered clearing all the file lists?
At the beginning, I was smart and thought that since the Code is automatically generated, why can't I directly Delete the code? (leave the code in a div empty .)? Think about it. The effect seems to be satisfactory. When the code is written, the problem is found.
What's the problem? Because the Multifile plug-in has a maximum number of files to control. On the surface, it seems that the file is clear. However, the internal file count counter is not cleared by colleagues. The most direct phenomenon is:
For example, if you set a maximum of five files and select five files, the file browsing button is automatically assigned to the disabled folder. Now that you have cleared the file, you cannot re-select the file.
What should we do?
I did not find this method on the Internet, but it was encapsulated by myself. The generated code is as follows:
The generated code shows the following connection:
<A class = "Multifile-Remove" href = "# upfile_warp"> in this connection, you can click this connection to delete a single file.
So try to write the following code:
Multifileclear = function (){
$ ("A. Multifile-Remove"). Each (function (I ){
This. Click ();
});
}
Test! OK!
------ Let's take a look at the jquery. mutlifile Code and provide a method.
/**
* This method removes all selected files
*
* Returns a jquery collection of all affected elements.
*
* @ Name Reset
* @ Type jquery
* @ Cat plugins/Multifile
* @ Author Diego A. (http://www.fyneworks.com /)
*
* @ Example $. FN. Multifile. Reset ();
*/
Reset: function (){
VaR settings = $ (this). Data ('multifile ');
// If (settings) settings. wrapper. Find ('A. Multifile-delete'). Click ();
If (settings) settings. List. Find ('A. Multifile-delete'). Click ();
Return $ (this );
},
Khan .. The idea is the same.