From 4e2843b4a1ca88a21137d7bb8adb193444a38835 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 27 Aug 2013 17:20:08 +0000 Subject: [PATCH] Implement set_value() to accept a list of files, which triggers the async upload and callbacks --- etemplate/js/et2_widget_file.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/etemplate/js/et2_widget_file.js b/etemplate/js/et2_widget_file.js index e9042d2adf..28d77e425d 100644 --- a/etemplate/js/et2_widget_file.js +++ b/etemplate/js/et2_widget_file.js @@ -268,7 +268,11 @@ var et2_file = et2_inputWidget.extend( }, /** - * You can't actually set value, but clearing works + * Set the value of the file widget. + * + * If you pass a FileList or list of files, it will trigger the async upload + * + * @param {FileList|File[]|false} value List of files to be uploaded, or false to reset. */ set_value: function(value) { if(!value || typeof value == "undefined") @@ -287,14 +291,10 @@ var et2_file = et2_inputWidget.extend( return; } - /* - // This would only look like it worked - var i = 0; - for(var key in value) + if(typeof value == 'object' && value.length && typeof value[0] == 'object' && value[0].name) { - this.createStatus(null,value.name,i++); + this.input[0].files = value; } - */ }, getInputNode: function() {