Hi Wolfgang,
It looks like you can achieve what you wish without redefining
finish_upload_status.
By default, finish_upload_status will forward its parameter to
your :finish handler declared in your form_tag_with_upload_progress
as such as ''arguments[0]'':
<%= form_tag_with_upload_progress({}, {:finish => ''updateContent
(arguments[0])'') %>
If wish to pass the redirect_to URL to your finish handler instead of
performing the redirect, you can call finish_upload_status directly
from your action by calling the undocumented function as such:
def upload_action
finish_upload_status("''#{erase_redirect_results)}''")
if
upload_progress
end
If there are javascript errors then the upload_status updater will
not get terminated. If you wish to explicitly terminate the updater
you can call the following function:
<%= upload_update_object %>.stop();
upload_update_object usually expands to "document.uploadStatus#
{current_upload_id}".
You may also wish to review http://sean.treadway.info/articles/
2005/07/18/upload-progress-checklist to confirm you are running an
environment that will show the update_status during the upload.
Hope this helps,
Sean
On Jul 22, 2005, at 11:57 PM, Wolfgang Wopperer wrote:
> Hi all,
>
> because I needed a file upload form that doesn''t result in a page
> reload but
> in an AJAX-driven content change on the client, I took the
> form_tag_with_upload_progress and modified it in the following way:
>
> I changed method finish_upload_status in
> ActionView::Helpers::UploadProgressHelper so that it doesn''t call
a
> client-side redirect anymore but a custom function. The redirect_to
> information from the controller is used as the parameter specifying
> the
> target resource:
>
> parent.updateContent(''#{escape_javascript options
> [:redirect_to]}''); //(line
> 270)
>
> In the updateContent() function, I do manually what the code
> generated by
> link_to_remote does:
>
> function updateContent(url) {
> new Ajax.Updater(''<some div>'', url,
{asynchronous:true,
> evalScripts:true});
> return false;
> }
>
> Everything works fine - when the upload is done, the content is being
> changed - except that the "upload watcher" doesn''t get
cancelled
> anymore and
> keeps requesting status information for the completed download:
>
> [WEBrick] - -> /folders/upload_status?upload_id=<id>
>
> On the client, this results in the following JavaScript error:
>
> Error: $("UploadProgressBar<i>") has no properties
> Source File: http://localhost:3000/javascripts/prototype.js
> Line: 331
>
> What do I have to do to stop the "upload watcher" on the client?
>
> Thanks for any hints!
>
> Wolfgang Wopperer
>
> mindmatters*
>
> * Neuer Kamp 30
> 20357 Hamburg
>
> Fon +49-(0)40-31 79 22 72
> Fax +49-(0)40-31 79 22 73
> E-Mail
mailto:wolfgang.wopperer-UkcLZtRm+6hlwAJJmLIKuQ@public.gmane.org
> Website www.mindmatters.de
>
> ----------------------------------------------------------------------
> ----
> Es läuft und läuft und läuft: Schon über 10.000 Downloads für JSF-
> Spring,
> unsere JSF-/Spring-Integrationslösung! Im Netz: jsf-
> spring.sourceforge.net
> ----------------------------------------------------------------------
> ----
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>