ithanshui / jquery-multifile-plugin

Automatically exported from code.google.com/p/jquery-multifile-plugin
0 stars 0 forks source link

No code to check if existing file is present then add it to the list and show it #165

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

In a form I am using this plugin. But, whenever there is some error while 
submitting the form. The file added to the MultiFile list is being removed 
although it is there in the background.

When I checked the plugin code there is no code to check if existing fie is 
there then add the slave and show the existing file. The reference for only 
adding the current selected file is at line no. 284.

/* 
// Add a new file to the list
       MultiFile.addToList = function( slave, slave_count ){
        //if(window.console) console.log('MultiFile.addToList',slave_count);

        //# Trigger Event! onFileAppend
        if(!MultiFile.trigger('onFileAppend', slave, MultiFile)) return false;
        //# End Event!

        // Create label elements
        var
         r = $('<div class="MultiFile-label"></div>'),
         v = String(slave.value || ''/*.attr('value)*/),
         a = $('<span class="MultiFile-title" title="'+MultiFile.STRING.selected.replace('$file', v)+'">'+MultiFile.STRING.file.replace('$file', v.match(/[^\/\\]+$/gi)[0])+'</span>'),
         b = $('<a class="MultiFile-remove" href="#'+MultiFile.wrapID+'">'+MultiFile.STRING.remove+'</a>');

        // Insert label
        MultiFile.list.append(
         r.append(b, ' ', a)
        );

        b
                                                                .click(function(){

          //# Trigger Event! onFileRemove
          if(!MultiFile.trigger('onFileRemove', slave, MultiFile)) return false;
          //# End Event!

          MultiFile.n--;
          MultiFile.current.disabled = false;

          // Remove element, remove label, point to current
                                                                                MultiFile.slaves[slave_count] = null;
                                                                                $(slave).remove();
                                                                                $(this).parent().remove();

          // Show most current element again (move into view) and clear selection
          $(MultiFile.current).css({ position:'', top: '' });
                                                                                $(MultiFile.current).reset().val('').attr('value', '')[0].value = '';

          //# Trigger Event! afterFileRemove
          if(!MultiFile.trigger('afterFileRemove', slave, MultiFile)) return false;
          //# End Event!

          return false;
        });

        //# Trigger Event! afterFileAppend
        if(!MultiFile.trigger('afterFileAppend', slave, MultiFile)) return false;
        //# End Event!

       }; // MultiFile.addToList
       // Add element to selected files list

*/

There is no code to similarly check the existing file and show them.

Kindly, provide a solution for this.

Original issue reported on code.google.com by sanjeev....@gmail.com on 31 Oct 2012 at 11:28