1

I am trying to have a progress bar for download operation. Here is my code. I am not able to set the value in the progress bar even though i m able to get the value

<div id = "progressbar" class="progress progress-striped active" style="display:none"><div id="progress-label" class ="bar">Loading...</div></div>
<script>
        $(function() {
                    var progressbar;
        progressbar = $( "#progressbar" ),
        progressLabel = $( ".progress-label" );
        progressbar.progressbar({
            value: false,
            change: function() {
                progressLabel.text( progressbar.progressbar( "value" ) + "%" );
            },
            complete: function() {
                progressLabel.text( "Complete!" );
            }
        });
    });

            var ft = new FileTransfer();
            $("#progressbar").show();
            ft.onprogress = function(progressEvent) {
            perc = Math.floor((progressEvent.loaded / progressEvent.total) * 100);
            progressbar.progressbar("value", perc);
            }
 </script>

2 Answers2

0

I guess that

$( "#progressbar" ).val(perc); 

does not work ?

This may be the correct syntax to update your progressbar:

$("#progressbar").progressbar({
    value: 35
});

According to this (and plenty more infos). You may try also another way.

Community
  • 1
  • 1
nicolallias
  • 1,055
  • 2
  • 22
  • 51
0

I just tested this and this should work for you:

    var ft = new FileTransfer();
                $("#progressbar").show();
                ft.onprogress = function(progressEvent) {

                perc = Math.floor((progressEvent.loaded / progressEvent.total) * 100);

                $("#progressbar").progressbar({value:perc}); //changed this line

                }
whodeee
  • 617
  • 5
  • 18