From: Felix Nagel Date: Sun, 11 Dec 2016 22:10:26 +0000 (+0100) Subject: Calendar: Make select and change event pass the current value X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=de20614bd7332b740c6ec095e0e5c48c2f97c8bf;p=jquery-ui.git Calendar: Make select and change event pass the current value --- diff --git a/tests/unit/calendar/events.js b/tests/unit/calendar/events.js index 59508cb8a..6dc2e5eef 100644 --- a/tests/unit/calendar/events.js +++ b/tests/unit/calendar/events.js @@ -12,12 +12,12 @@ QUnit.module( "calendar: events", { } ); QUnit.test( "change", function( assert ) { - assert.expect( 6 ); + assert.expect( 8 ); var shouldFire, eventType; this.element.calendar( { - change: function( event ) { + change: function( event, ui ) { assert.ok( shouldFire, "change event fired" ); assert.equal( event.type, @@ -29,6 +29,7 @@ QUnit.test( "change", function( assert ) { eventType, "change originalEvent on calendar button " + eventType ); + assert.equal( $.type( ui.value ), "date", "value is a date object" ); } } ); @@ -48,14 +49,14 @@ QUnit.test( "change", function( assert ) { } ); QUnit.test( "select", function( assert ) { - assert.expect( 6 ); + assert.expect( 8 ); var ready = assert.async(), that = this, message, eventType; this.element.calendar( { - select: function( event ) { + select: function( event, ui ) { assert.ok( true, "select event fired " + message ); assert.equal( event.type, @@ -67,6 +68,7 @@ QUnit.test( "select", function( assert ) { eventType, "select originalEvent " + message ); + assert.equal( $.type( ui.value ), "date", "value is a date object" ); } } ); diff --git a/ui/widgets/calendar.js b/ui/widgets/calendar.js index 538230bb6..0c961a3d7 100644 --- a/ui/widgets/calendar.js +++ b/ui/widgets/calendar.js @@ -134,13 +134,13 @@ return $.widget( "ui.calendar", { this._updateDayElement( "ui-state-active" ); // Allow datepicker to handle focus - if ( this._trigger( "select", event ) !== false ) { + if ( this._trigger( "select", event, { value: this.options.value } ) !== false ) { this.activeDescendant.closest( this.grid ).focus(); event.preventDefault(); } if ( oldValue !== this.options.value.getTime() ) { - this._trigger( "change", event ); + this._trigger( "change", event, { value: this.options.value } ); } },