PDA

View Full Version : UpdateManager Abort not working when uploading files


bahar
04-28-2007, 06:07 AM
I'm using UpdateManager formUpdate method to upload some files. It works fine but when I wanted to add a cancel button that user can cancel uploads, I assumed calling the Abort method of the UpdateManager will do the trick, but it does nothing!
for make the cancel work I had to manually select the iframe that is used for upload process and Stop it.
I don't know if this is the best way to cancel the uploads but I think the Abort method should cancel the upload process.

Animal
04-28-2007, 06:21 AM
formUpdate does a form submission, not an XHR. It's a native browser operation, and can't be aborted programatically.

bahar
04-28-2007, 07:20 AM
That's right but Abort method should be kinda smart to check if the form has the attribute enctype="multipart/form-data" then stops the form submission in the automatically created iframe.

Animal
04-28-2007, 07:36 AM
How?

bahar
04-28-2007, 08:25 AM
Here's what I'm doing to stop the form submission:


Ext.Element.select('iframe').each(function(elm) {
mainWindow = elm.dom.contentWindow;
if (mainWindow && mainWindow.stop)
mainWindow.stop();
else if (mainWindow && mainWindow.document && mainWindow.document.execCommand)
mainWindow.document.execCommand('Stop');
});
Ext.Element.select('iframe').each(function(elem){ elem.remove(); });

Animal
04-28-2007, 09:59 AM
Yep, that will ensure the onready callback doesn't get fired.

In fact, the problem lies with YUI. The abort function does not delete the iframe.

If I were you, I'd log a bug request at the YUI sourceforge page. They could eaily add that. The id of the iframe is "yuiIO" + the transaction id, so they could drop the iframe in the abort call.

I'd go to sourceforge and second that request - it's a good idea.

bahar
04-28-2007, 02:25 PM
It seems that you sent the request to the SourceForge. Thanks

Animal
04-28-2007, 02:35 PM
Yeah, I thought they should support it. After you mentioned it, I saw that the YAHOO.util.Connect API doesn't support its own operations consistently for both submission methods.