Skip to content

Commit 0b6710a

Browse files
committed
Progressbar: Added a complete event. Fixes #3500 - Progressbar callback at the end.
1 parent adcafce commit 0b6710a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/unit/progressbar/progressbar_events.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,25 @@ test("change", function() {
1414
}).progressbar("value", 5);
1515
});
1616

17+
test( "complete", function() {
18+
expect( 3 );
19+
var changes = 0,
20+
value;
21+
22+
$( "#progressbar" ).progressbar({
23+
change: function() {
24+
changes++;
25+
same( $( this ).progressbar( "value" ), value, "change at " + value );
26+
},
27+
complete: function() {
28+
equal( changes, 2, "complete triggered after change" );
29+
}
30+
});
31+
32+
value = 5;
33+
$( "#progressbar" ).progressbar( "value", value );
34+
value = 100;
35+
$( "#progressbar" ).progressbar( "value", value );
36+
});
37+
1738
})(jQuery);

ui/jquery.ui.progressbar.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ $.widget( "ui.progressbar", {
6464
this.options.value = value;
6565
this._refreshValue();
6666
this._trigger( "change" );
67+
if ( this._value() === this.max ) {
68+
this._trigger( "complete" );
69+
}
6770
}
6871

6972
$.Widget.prototype._setOption.apply( this, arguments );

0 commit comments

Comments
 (0)