]> source.dussan.org Git - jquery-ui.git/commitdiff
Progressbar: Added a complete event. Fixes #3500 - Progressbar callback at the end.
authorScott González <scott.gonzalez@gmail.com>
Mon, 27 Sep 2010 14:44:04 +0000 (10:44 -0400)
committerScott González <scott.gonzalez@gmail.com>
Mon, 27 Sep 2010 14:44:04 +0000 (10:44 -0400)
tests/unit/progressbar/progressbar_events.js
ui/jquery.ui.progressbar.js

index b273cd5e99427f6add8d5eee1f122142280f87d8..22b301abe03c9515faa0a3a83cfde66a34c38b19 100644 (file)
@@ -14,4 +14,25 @@ test("change", function() {
        }).progressbar("value", 5);
 });
 
+test( "complete", function() {
+       expect( 3 );
+       var changes = 0,
+               value;
+       
+       $( "#progressbar" ).progressbar({
+               change: function() {
+                       changes++;
+                       same( $( this ).progressbar( "value" ), value, "change at " + value );
+               },
+               complete: function() {
+                       equal( changes, 2, "complete triggered after change" );
+               }
+       });
+       
+       value = 5;
+       $( "#progressbar" ).progressbar( "value", value );
+       value = 100;
+       $( "#progressbar" ).progressbar( "value", value );
+});
+
 })(jQuery);
index e0b728f1a249f1367c4bef194e6c46926e76ac42..5347e026b7a0ed69a55fea8451ac350a69e3b4da 100644 (file)
@@ -64,6 +64,9 @@ $.widget( "ui.progressbar", {
                        this.options.value = value;
                        this._refreshValue();
                        this._trigger( "change" );
+                       if ( this._value() === this.max ) {
+                               this._trigger( "complete" );
+                       }
                }
 
                $.Widget.prototype._setOption.apply( this, arguments );