how can i reuse progressbar that is created by jquery in a div
I want to use the same progressbar multiple ti开发者_高级运维mes that is crated by jquery in a div. So how can i reinitiate the progressbar.
What's stopping you from just doing $('#yourelement').progressbar('value', 0);
to reset the progress bar back to 0%?
Unless you're not using jQuery UI, in which cause you'd just have to do $('#yourelement').width('0%')
or something similar.
$('#yourprogressbarid').progressbar('option', 'value', 0);
Assuming you are using jQuery UI progressbar.
perhaps this would help:
I had a problem when re-using a JQuery ProgressBar, because when you reset the progress bar to 0, it takes some time for the bar to move back to 0 (since ProgressBar smoothly moves from one value to the next).
My answer was to reset the progressBar to 0, when it is hidden.
So the algorithm is:
- process starting (e.g. file upload)
- show progress bar
update progress as the process completes
$('#jqProgressID').progressBar(percent);
when process completes, hide the progress bar
NOW reset the progress bar to 0:
$('#jqProgressID').progressBar(0);
This allows you to re-use the progress bar, without the user having to view the bar resetting to 0.
精彩评论