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

Re-apply HTML5 Filter After Removing File

1 Answer 25 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 21 Feb 2017, 08:51 PM

I am using $('.ruFileInput').attr('accept', 'image/*'); to apply a filter on an AsnycUpload control with MaxFileInputsCount set to 1. This works great on initial load, but if a user removes the file and clicks to upload a new one, the filter is no longer applied.  I tried using the same jQuery code to re-apply the filter in the OnClientFileUploadRemoved event, but the ruFileInput element hasn't been recreated at this point, so it doesn't work.  Any ideas on how else I can re-apply the filter after a file is removed?

1 Answer, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 24 Feb 2017, 12:56 PM
Hello Michael,

Wrapping the attribute setting logic in a function called by setTimeout should allow the input to render before executing the attribute logic:

function OnClientFileUploadRemoved() {
    setTimeout(function () {
        $telerik.$('.ruFileInput').attr('accept', 'image/*');
    });
}

Here is a forum thread that would help you better understand what the setTimeout function achieves: Why is setTimeout(fn, 0) sometimes useful?

Regards,
Peter Milchev
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
AsyncUpload
Asked by
Michael
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Share this question
or