RadAsyncUpload manual hide/show javascript

Thread is closed for posting
2 posts, 0 answers
  1. Marcin
    Marcin avatar
    165 posts
    Member since:
    Jan 2011

    Posted 24 Feb 2011 Link to this post

    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.
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 25 Feb 2011 Link to this post

    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!
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top