From 248f0e9d0881732fef79b005064e5b76feb22069 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 30 May 2012 23:14:35 +0200 Subject: [PATCH] Fix: reload page after file upload completed --- htdocs/core/tpl/ajax/fileupload_main.tpl.php | 28 +++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/htdocs/core/tpl/ajax/fileupload_main.tpl.php b/htdocs/core/tpl/ajax/fileupload_main.tpl.php index 0ceddff436b..af184cdb48c 100644 --- a/htdocs/core/tpl/ajax/fileupload_main.tpl.php +++ b/htdocs/core/tpl/ajax/fileupload_main.tpl.php @@ -39,16 +39,38 @@ window.locale = { $(function () { 'use strict'; - var max_file_size = ''; - // Initialize the jQuery File Upload widget: $('#fileupload').fileupload(); // Options $('#fileupload').fileupload('option', { - maxFileSize: max_file_size + maxFileSize: '' }); + // Events + $('#fileupload') + .bind('fileuploaddestroy', function (e, data) { + var that = $(this).data("fileupload"); + if ( confirm("Delete this file ?") == true ) { + if (data.url) { + $.ajax(data).success(function () { + that._adjustMaxNumberOfFiles(1); + $(this).fadeOut(function () { + $(this).remove(); + }); + }); + } else { + data.context.fadeOut(function () { + $(this).remove(); + }); + } + } + }) + .bind('fileuploadcompleted', function (e, data) { + $.ajax(data).success(function () { + location.href=''; + }); + }); }); \ No newline at end of file