How To Use Jquery Ui Progress Bar?
I am trying to use jquery ui progress bar with valum file upload plugin. Code : ..... onProgress: function (id, fileName, uploadedByt
Solution 1:
Assuming 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:
<scripttype="text/javascript">var i = 0; //variable used to count the stepsfunctionmyclick(){ // function called on a button click for examplevar 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.
Solution 2:
You need to calculate the amount of uploaded bytes in percent.
var percentValue = (uploadedBytes / totalBytes) * 100
$("#pb").progressbar({
value: percentValue
});
Solution 3:
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.
Post a Comment for "How To Use Jquery Ui Progress Bar?"