]> source.dussan.org Git - jquery-ui.git/commitdiff
Progressbar: Modified value method to act as both a getter and setter. Fixed #4427...
authorScott González <scott.gonzalez@gmail.com>
Thu, 16 Apr 2009 01:57:56 +0000 (01:57 +0000)
committerScott González <scott.gonzalez@gmail.com>
Thu, 16 Apr 2009 01:57:56 +0000 (01:57 +0000)
tests/unit/progressbar/progressbar_methods.js
ui/ui.progressbar.js

index 9a162685bfa914e9dc5de73465fc1cecbf7f4ed3..a48fa3d4705c83b5df5e6eaa5115405224be6eea 100644 (file)
@@ -24,4 +24,13 @@ test("destroy", function() {
        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);
index 6988f8dffb49949fa5dffc3598d1e6a63abffdd9..1cf077cae0ebbf8840ab1cce87e726b322f20932 100644 (file)
@@ -56,8 +56,12 @@ $.widget("ui.progressbar", {
        },
 
        value: function(newValue) {
-               arguments.length && this._setData("value", newValue);
-               return this._value();
+               if (newValue === undefined) {
+                       return this._value();
+               }
+               
+               this._setData('value', newValue);
+               return this;
        },
 
        _setData: function(key, value) {