最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - changing the values of jquery ui progress bar - Stack Overflow

programmeradmin5浏览0评论

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 });
});

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 });
});
Share Improve this question edited Jun 21, 2011 at 6:12 mu is too short 435k71 gold badges858 silver badges818 bronze badges asked Jun 21, 2011 at 6:04 hilarlhilarl 6,88013 gold badges51 silver badges58 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 11

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./demos/progressbar/

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

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

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

发布评论

评论列表(0)

  1. 暂无评论