File tree Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Expand file tree Collapse file tree 2 files changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -278,13 +278,10 @@ QUnit.test( "numberOfMonths", function( assert ) {
278
278
279
279
var date = new Date ( 2015 , 8 - 1 , 1 ) ;
280
280
281
- // Number of month option does not work after init
282
- this . element
283
- . calendar ( "destroy" )
284
- . calendar ( {
285
- numberOfMonths : 3 ,
286
- value : date
287
- } ) ;
281
+ this . element . calendar ( "option" , {
282
+ numberOfMonths : 3 ,
283
+ value : date
284
+ } ) ;
288
285
289
286
assert . equal ( this . widget . find ( ".ui-calendar-group" ) . length , 3 , "3 calendar grids" ) ;
290
287
assert . equal (
@@ -304,10 +301,7 @@ QUnit.test( "numberOfMonths", function( assert ) {
304
301
"After mousedown last month: Last day is Saturday"
305
302
) ;
306
303
307
- // Test if using cursor to go to the next / prev month advances three month
308
- // Focus doesn't work here so we use an additional mouse down event
309
- this . widget . find ( "tbody:first td[id]:first button" ) . trigger ( "mousedown" ) ;
310
- $ ( document . activeElement ) . simulate ( "keydown" , { keyCode : $ . ui . keyCode . LEFT } ) ;
304
+ this . widget . find ( "button.ui-calendar-prev" ) . simulate ( "click" ) ;
311
305
assert . equal ( this . widget . find ( ".ui-calendar-month:first" ) . text ( ) , "May" ,
312
306
"After move to previous month: First month is May"
313
307
) ;
Original file line number Diff line number Diff line change @@ -703,12 +703,16 @@ return $.widget( "ui.calendar", {
703
703
704
704
_setOptions : function ( options ) {
705
705
var that = this ,
706
+ create = false ,
706
707
refresh = false ,
707
708
dateAttributes = false ;
708
709
709
710
$ . each ( options , function ( key , value ) {
710
711
that . _setOption ( key , value ) ;
711
712
713
+ if ( key === "numberOfMonths" ) {
714
+ create = true ;
715
+ }
712
716
if ( key in that . refreshRelatedOptions ) {
713
717
refresh = true ;
714
718
}
@@ -722,8 +726,16 @@ return $.widget( "ui.calendar", {
722
726
this . date . setAttributes ( this . _calendarDateOptions ) ;
723
727
this . viewDate . setAttributes ( this . _calendarDateOptions ) ;
724
728
}
725
- if ( refresh ) {
729
+ if ( create || refresh ) {
726
730
this . viewDate . setTime ( this . date . date ( ) . getTime ( ) ) ;
731
+ }
732
+ if ( create ) {
733
+ this . element . empty ( ) ;
734
+ this . _removeClass ( this . element , "ui-calendar-multi" ) ;
735
+ this . _createCalendar ( ) ;
736
+ refresh = false ;
737
+ }
738
+ if ( refresh ) {
727
739
this . refresh ( ) ;
728
740
}
729
741
} ,
You can’t perform that action at this time.
0 commit comments