diff options
author | Patrick McKay <patrick.mckay@vumc.org> | 2020-03-01 07:13:05 -0600 |
---|---|---|
committer | Felix Nagel <fnagel@users.noreply.github.com> | 2021-05-21 17:58:10 +0200 |
commit | 17d115b8298b935ab0d26b881d4f6f3e83984868 (patch) | |
tree | a5e01e37af5a3a2ccf21285b11a962584aaaef17 /tests/unit | |
parent | b864cd103a0acb76b0a34fb1dd382dc0925ef9a8 (diff) | |
download | jquery-ui-17d115b8298b935ab0d26b881d4f6f3e83984868.tar.gz jquery-ui-17d115b8298b935ab0d26b881d4f6f3e83984868.zip |
Datepicker: Add option for onUpdateDatepicker callback
Add a new option named onUpdateDatepicker that allows a custom callback
to be provided. If provided, the callback is called at the end of
$.datepicker._updateDatepicker.
Diffstat (limited to 'tests/unit')
-rw-r--r-- | tests/unit/datepicker/options.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/unit/datepicker/options.js b/tests/unit/datepicker/options.js index e58b9a75d..0ce771c5e 100644 --- a/tests/unit/datepicker/options.js +++ b/tests/unit/datepicker/options.js @@ -813,7 +813,9 @@ var beforeShowThis = null, beforeShowInput = null, beforeShowInst = null, beforeShowDayThis = null, - beforeShowDayOK = true; + beforeShowDayOK = true, + onUpdateDatepickerThis = null, + onUpdateDatepickerInst = null; function beforeAll( input, inst ) { beforeShowThis = this; @@ -830,8 +832,14 @@ function beforeDay( date ) { ( date.getDate() % 3 === 0 ? "Divisble by 3" : "" ) ]; } +function onUpdateDatepicker( inst ) { + onUpdateDatepickerThis = this; + onUpdateDatepickerInst = inst; + inst.dpDiv.append( $( "<div>" ).addClass( "on-update-datepicker-test" ) ); +} + QUnit.test( "callbacks", function( assert ) { - assert.expect( 13 ); + assert.expect( 16 ); // Before show var dp, day20, day21, @@ -860,6 +868,14 @@ QUnit.test( "callbacks", function( assert ) { assert.ok( !day20.attr( "title" ), "Before show day - title 20" ); assert.ok( day21.attr( "title" ) === "Divisble by 3", "Before show day - title 21" ); inp.datepicker( "hide" ).datepicker( "destroy" ); + + inp = testHelper.init( "#inp", { onUpdateDatepicker: onUpdateDatepicker } ); + inst = $.data( inp[ 0 ], "datepicker" ); + dp = $( "#ui-datepicker-div" ); + inp.val( "02/04/2008" ).datepicker( "show" ); + assert.ok( onUpdateDatepickerThis.id === inp[ 0 ].id, "On update datepicker - this OK" ); + assert.deepEqual( onUpdateDatepickerInst, inst, "On update datepicker - inst OK" ); + assert.ok( dp.find( "div.on-update-datepicker-test" ).length > 0, "On update datepicker - custom element" ); } ); QUnit.test( "beforeShowDay - tooltips with quotes", function( assert ) { |