Skip to content

Commit

Permalink
Progressbar: Modified value method to act as both a getter and setter…
Browse files Browse the repository at this point in the history
…. Fixed #4427 - progressbar('value') returns a reference to this instead of the value.
  • Loading branch information
scottgonzalez committed Apr 16, 2009
1 parent 1195854 commit 62f11b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
9 changes: 9 additions & 0 deletions tests/unit/progressbar/progressbar_methods.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ test("destroy", function() {
equals(actual, expected, 'destroy is chainable'); equals(actual, expected, 'destroy is chainable');
}); });


test('value', function() {
expect(3);

var el = $('<div></div>').progressbar({ value: 20 });
equals(el.progressbar('value'), 20, 'correct value as getter');
equals(el.progressbar('value', 30), el, 'chainable as setter');
equals(el.progressbar('option', 'value'), 30, 'correct value after setter');
});

})(jQuery); })(jQuery);
8 changes: 6 additions & 2 deletions ui/ui.progressbar.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ $.widget("ui.progressbar", {
}, },


value: function(newValue) { value: function(newValue) {
arguments.length && this._setData("value", newValue); if (newValue === undefined) {
return this._value(); return this._value();
}

this._setData('value', newValue);
return this;
}, },


_setData: function(key, value) { _setData: function(key, value) {
Expand Down

0 comments on commit 62f11b4

Please sign in to comment.