I have an issue with jQuery UI Progress bars. I got multiple progress bars on my page (for stacked progress bars indicating a multi-step progress) and I have the following code to initiate the progress bar and assign the value :
function createProgressBars(progressVal, progressValMax, callback) {
progressVal = $(this).data("progress-value");
progressValMax = $(this).data("progress-val-max");
$(".progress-bar").progressbar({
value : progressVal,
max : progressValMax
});
callback();}
jQuery(function($){
$(document).ready(function(){
$(".progress-bar").each(function(){
var pv = $(this).data("progress-value"),
pm = $(this).data("progress-max");
createProgressBars(pv, pm);
});
});
});
EDIT : Added HTML Code
<div class="progress-bar regular-user" data-progress-value="1000" data-progress-max="3000"></div>
<div class="progress-bar bronze-user" data-progress-value="500" data-progress-max="2000"></div>
<div class="progress-bar silver-user" data-progress-value="300" data-progress-max="2000"></div>
<div class="progress-bar gold-user" data-progress-value="200" data-progress-max="3000"></div>
But in the HTML attributes I have aria-value-max=100 and aria-value-now=0 .
How can I specify those values correctly? I had the same experience with a progress bar (a single one actually) and it worked fine.
Thanks guys.
The first thing you do in
createPogressBaris to overwrite the two parameters withthisthat does not point to anything at that point. You could probably do:Or move the code to your
createProgressBarfunction by sending only thethisparameter.EDIT: I updated both codes. In the first case, we need to use
thisto create the right progress bar, not the general selector.In the second case, we need to use the container.
Not doing so tries to re-generate all progress bars every time, which caused weird effects.