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

Upload - last item removal

3 Answers 96 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 31 Mar 2014, 09:21 PM
This feels like it should be a simple question, but I can't find the answer anywhere.

If a user clicks the remove button (x) on the only file in an upload list, the file is removed from the list and the 'upload' button is hidden. How can I simulate this?

I'm overriding the 'onselect' event and checking for existing files in a directory. If the user selects 'no, I don't want to replace the existing file', I'm removing the item from the upload list successfully, but if it's the only file in the list, I'm left with the button and a border around the empty list.

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 01 Apr 2014, 12:59 PM
Hi Paul,

The easiest approach in the current case would be to trigger the click event of the remove button of the list item. This way the widget will automatically check if the file list is empty and apply the appropriate changes.
E.g.
$(".k-upload").find(".k-file .k-delete").closest("button").click()

Regards,
Dimiter Madjarov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Paul
Top achievements
Rank 1
answered on 01 Apr 2014, 01:37 PM
Thanks Dimiter,

Your response gave me the information I needed. I had access to the name of the file I wanted to delete, so I've modified your code to achieve the desired result, as follows:

function removeFile(fileName) {
 
    var li = $(".k-upload-files").find("[title='" + fileName + "']").parent();
 
    $(li).find(".k-delete").closest("button").click()
 
}


Paul
0
Dimiter Madjarov
Telerik team
answered on 01 Apr 2014, 01:53 PM
Hi Paul,

I am glad that the issue is resolved. Do not hesitate to contact us again if further issues arise.

I wish you a great day!

Regards,
Dimiter Madjarov
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
Upload
Asked by
Paul
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Paul
Top achievements
Rank 1
Share this question
or