Skip to content

Commit

Permalink
Progressbar: Added a complete event. Fixes #3500 - Progressbar callba…
Browse files Browse the repository at this point in the history
…ck at the end.
  • Loading branch information
scottgonzalez committed Sep 27, 2010
1 parent adcafce commit 0b6710a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/unit/progressbar/progressbar_events.js
Expand Up @@ -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);
3 changes: 3 additions & 0 deletions ui/jquery.ui.progressbar.js
Expand Up @@ -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 );
Expand Down

0 comments on commit 0b6710a

Please sign in to comment.