2amigos / yii2-file-upload-widget

BlueImp File Upload Widget for Yii2
Other
252 stars 140 forks source link

Init plugin with DB values #117

Closed robov closed 7 years ago

robov commented 7 years ago

When my page loads I would like to show the list of the items already in the database. How do I show the list on a page load ?

robov commented 7 years ago

For all that have the same issue... here is the solution. Place this js AFTER the echo of the widget, otherwise you get errors of calling before initialization

$.ajax({
    url: 'freepost/initlist',
    dataType: 'json',
    context: $('#dstransfersender-image-fileupload')[0]
}).done(function (init_data) 
{
    var form = $('#dstransfersender-image-fileupload');
    form.fileupload('option', 'done').call(form, $.Event('done'), {result: init_data}); 
});    
tonydspaniard commented 7 years ago

Thanks for the information @robov . I normally do show the already uploaded files with a partial view or a different section, where user can CRUD images at will. Your solution is good too. Thanks again.