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

RadAsyncUpload manual hide/show javascript

1 Answer 80 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Marcin
Top achievements
Rank 1
Veteran
Marcin asked on 24 Feb 2011, 02:43 PM
Hello, I'm trying to make manual handle when to show/hide inputs for radasyncupload.

var filesUploaded = 1;
var maxFileCount = 2;
  
function FileSelected(sender, args) {
    filesUploaded++;
      
    if (maxFileCount == filesUploaded)
         $(".ruInputs > li:last").remove();        
}
  
function FileUploadRemoved(sender, args) {
    if (maxFileCount == filesUploaded)
        sender.addFileInput();
  
    filesUploaded--;         
}
Following code works quite well if fileUploaded is initialy 0. But once I need to set it to 1 on the beginning.

Scenario is following:
Add file. - input disapears. - correct
remove file - two inputs is showing.

I would like to prevent such scenario.
I don't have MaxFileInputsCount set to control - I don't like the way how it is handling file. And it causing me other problems.

And more thing. I don't know whay but e.g. in firefox 4b11. After some adds and removes clicking on control not working. Looks like silverlight not support clicking any more. (Silverlight is loading by default). The version I have is 2010.3.1317.40. Ican click multiple times and sometimes it is working sometimes not.

1 Answer, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 25 Feb 2011, 05:12 PM
Hi Marcin,

If there is only one input added to RadAsyncUpload and it is removed afterwards, RadAsyncUpload will auto add a new input. This means that there is no need to call

sender.addFileInput();

In fact, this line is causing the issue that you experience. I suggest that you use the following setup instead:

<script type="text/javascript">
    var filesUploaded = 1;
    var maxFileCount = 2;
    var $ = $telerik.$;
 
    function FileSelected(sender, args) {
        filesUploaded++;
 
        if (maxFileCount == filesUploaded)
            $(".ruInputs > li:last").remove();
    }
 
    function FileUploadRemoved(sender, args) {
        if (maxFileCount == filesUploaded && $(".ruInputs li", sender.get_element()).size() != 0)
            sender.addFileInput();
 
        filesUploaded--;
    }
</script>


Best wishes,
Genady Sergeev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
Upload (Obsolete)
Asked by
Marcin
Top achievements
Rank 1
Veteran
Answers by
Genady Sergeev
Telerik team
Share this question
or