This is a migrated thread and some comments may be shown as answers.

Check if Upload Initialized

2 Answers 351 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Ashleigh L
Top achievements
Rank 1
Ashleigh L asked on 12 Nov 2015, 08:10 PM

Is there any way to programmatically check if an upload widget has been initialized?

I've got a bit of an odd situation, where the same child upload can be associated with multiple parents on the page and I'm trying to set the file list on page load. Since the child exists twice, the (single) file is being displayed twice on each of the two widgets. 

I'm using a class to target the children items to add an upload, since they have the same ID:

<input class="upload-#= data.Items[i].ID #" type="file" />

Then when I init the upload, I'm creating a files array:

for (var i = 0; i < data.Items.length; i++) {      
    var files = [];
                     
    for (var a = 0; a < data.Items[i].Attachments.length; a++) {                       
        files.push({
            name: data.Items[i].Attachments[a].Name,
            size: data.Items[i].Attachments[a].Size,
            extension: data.Items[i].Attachments[a].Extension
        });                
    }                  
                     
    $('.rcr-upload-' + data.Items[i].ID).kendoUpload({
        multiple: true,
        async: {
            saveUrl: "/controllers/UploadController.cfc?method=upload",
            autoUpload: true
        },
        files: files
    });
}

When I console.log the files array, it only has the one item in it, so it looks like the duplication is happening because the inputs have the same class (which again, is because the ID is the same). There's no unique ID I can provide for these items, so I'm hoping to check if the widget has been init'd instead.

2 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 13 Nov 2015, 08:22 AM

Hello shimmoril,

In order to check whether the widget is initialized, you could retrieve the Upload widget instance object

var upload = $(...).data("kendoUpload");
and check if it returns the actual object and not undefined.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ashleigh L
Top achievements
Rank 1
answered on 16 Nov 2015, 04:10 PM
Thanks.
Tags
Upload
Asked by
Ashleigh L
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Ashleigh L
Top achievements
Rank 1
Share this question
or