Interacting with the MultiFile Upload Plugin
|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Interacting with the MultiFile Upload Plugin
by musetracks
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message I'm working on a project where I'm using two plugins in tandem, if you will. I'm using the MultiFile plugin and the AjaxFileUpload plugin together to validate files (size, etc.) at the time they're selected. The sequence looks like this:
1. User selects a file which triggers the change event. 2. The MultiFile plugin's built-in handler does its then and then a custom handler uses the ajaxFileUpload plugin to upload the selected file for validation, etc. 3. Any errors are returned and reported. My question is similar to that asked in this thread. If there's an error, I need to remove the invalid input. I've done this manually, but the manual operation doesn't decrement the counter that is tested for compliance with any max fields setting. How can I interact more effectively with the MultiFile plugin? Specifically, I'd really like to know if/how I can trigger the plugin's native function to delete a file input. If I can make that happen, then the counter will be decremented automatically for me. Any help would be much appreciated. Everything I've tried has failed. Badly. Thank you. Rob Wilkerson |
|
|
Re: Interacting with the MultiFile Upload Plugin
by Diego A.
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message I agree with you the plugin lacks in programmatic interaction. At the moment, there is no way to call the plugin's native 'remove file' function. The only thing you can do is use the 'onFileAppend' event to fail the file's validation.
But I realise the need for such functionality and I'm going to make sure it's available next time I update the plugin, hopefully by the end of this week (15th Oct 2007).
|
|
|
Re: Interacting with the MultiFile Upload Plugin
by musetracks
::
Rate this Message:
Reply (Restricted by the Administrator) | Reply to Author | View Threaded | Show Only this Message No problem. I ended up getting what I needed using the DOM. I isolated the "delete" link and manually triggered the click event. That way I was able to use your code rather than duplicating anything. In case anyone else is interested: $.ajaxFileUpload ({ url: '/api/rest/creative/upload', secureuri: false, fileElementId: input.id, dataType: 'json', success: function ( data, status ) { try { /** * If there's an error in the upload process, remove the relevant * UI elements. To do this, we'll trigger the click event which * will then be handled by code in the MultiFile plugin. */ if ( data['error'].length > 0 ) { $('a[href^="#multimulti_"]:last').trigger ( 'click' ); alert ( data['error'] ); } else { ... No error. Do stuff ... } } catch ( e ) { $('a[href^="#multimulti_"]:last').trigger ( 'click' ); alert ( 'Error: ' + e.message ); } }, error: function ( data, status, e ) { $('a[href^="#multimulti_"]:last').trigger ( 'click' ); alert ( 'An error occurred:\n\n' + e + ' (' + status + ')' ); }, }); |
| Free Forum Powered by Nabble | Forum Help |