admin管理员组文章数量:1332373
I am trying to use jquery ui progress bar with valum file upload plugin. Code :
<div id="pb"></div>
.....
onProgress: function (id, fileName, uploadedBytes, totalBytes) {
$("#pb").progressbar({ value : uploadedBytes });
},
. .... .
But this is not working, can anybody pls guid me, how to use progress bar properly ?
I am trying to use jquery ui progress bar with valum file upload plugin. Code :
<div id="pb"></div>
.....
onProgress: function (id, fileName, uploadedBytes, totalBytes) {
$("#pb").progressbar({ value : uploadedBytes });
},
. .... .
But this is not working, can anybody pls guid me, how to use progress bar properly ?
Share Improve this question asked Sep 9, 2012 at 10:46 GauravGaurav 8,48714 gold badges57 silver badges91 bronze badges 2- not working is too broad of a description. It might just be unrelated errors stopping your script from working. – TigOldBitties Commented Sep 9, 2012 at 10:57
- Did my answer help you? Let me know the oute.. – ffffff01 Commented Sep 12, 2012 at 19:58
3 Answers
Reset to default 2Assuming you have an html with a <div id="progressbar"></div>
the following code will step through the progressbar once every 10 miliseconds untill it reaches 100:
<script type="text/javascript">
var i = 0; //variable used to count the steps
function myclick(){ // function called on a button click for example
var int = self.setInterval(
function(){
if (i == 100) window.clearInterval(int);
$( "#progressbar" ).progressbar("value", i);
i++;
}
, 10);
}
$('button').button().click(myclick); // a button element which will
// start the progress bar
$( "#progressbar" ).progressbar(); //this part sets up the progressbar
</script>
Note: The other answers are also valid, I only posted this answer as an answer to "How to properly use a progressbar" part of the question which IMO has not been answered.
You need to calculate the amount of uploaded bytes in percent.
var percentValue = (uploadedBytes / totalBytes) * 100
$("#pb").progressbar({
value: percentValue
});
The progress bar works in percentages. You will need to convert uploadedBtyes
to a % of the totalBytes
and then pass this as a number to the value property of the options.
本文标签: javascripthow to use jquery ui progress barStack Overflow
版权声明:本文标题:javascript - how to use jquery ui progress bar? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742308209a2450345.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论