1

我正在尝试为下载操作设置进度条。这是我的代码。即使我能够获取值,我也无法在进度条中设置值

<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>
4

2 回答 2

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

                }
于 2013-05-28T18:48:39.597 回答
0

我猜是

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

不工作?

这可能是更新进度条的正确语法:

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

根据this(以及更多信息)。您也可以尝试另一种方式

于 2013-05-27T13:35:34.810 回答