clevertech/YiiBooster — pull request #884 by bobnvic (2014-07-04 01:20:18+00:00)
Title: Add callbacks to TbFileUpload

Add callbacks based on work by Szymon Dudziak, given in comment #14486 at http://www.yiiframework.com/wiki/430/how-to-use-yiibooster-tbfileupload-widget/.

His comment:
Missing callbacks ...
So I've added them. Please take a look.

Changes are pasted here (diff): http://pastebin.com/fET6zviZ

Please also read documentation here: https://github.com/blueimp/jQuery-File-Upload/wiki/Options

Here's a sample code how to use callbacks:

(In some view file)

$this->widget('bootstrap.widgets.TbFileUpload', array(
'url' => $this->createUrl('image/upload'),
'imageProcessing' => false,
'name' => 'photo',
'multiple' => false,
'callbacks' => array(
'done' => new CJavaScriptExpression(
'function(e, data) { alert(\'done!\'); }'
),
'fail' => new CJavaScriptExpression(
'function(e, data) { alert(\'fail!\'); }'
),
),
)
);
So, for example you can refresh your list after upload.

Regards, Simon

I have found this addition to be very useful and would like to see it added to the official source.