Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

changing the values of jquery ui progress bar

i am trying to change the values of the progress bar widget to accept a json string i am getting which is something like:

{
  'totalDays' : 31,
  'daysTaken' : 20
}

so i want the 'totalDays' to be the total value of the progress bar (total length) and the 'daysTaken' to fill the progress bar.

according to the default docs, only the filled value is possible to change:

$(document).ready(function() {
  $("#progressbar").progressbar({ value: 37 });
});
like image 902
hilarl Avatar asked Jun 21 '11 06:06

hilarl


2 Answers

There is a separate method to set the value after init.

var obj = {totalDays: 31, daysTaken: 20};
$("#progressbar").progressbar('value', obj.daysTaken/obj.totalDays * 100);

There is no configurable max value, but it's really not necessary since it is easy normalize values.

http://jqueryui.com/demos/progressbar/

like image 142
Matt Ball Avatar answered Sep 20 '22 12:09

Matt Ball


This is how you set the value of jquery-ui's progress bar

$( ".selector" ).progressbar( "option", "value", 37 );

Source, the documentation at http://jqueryui.com/demos/progressbar/#option-value

like image 45
sharat87 Avatar answered Sep 21 '22 12:09

sharat87