大部分的人會預設ready就載入
$( document ).ready( function() {
$( "input.date" ).datepicker({
minDate: moment().subtract( "months", 1 ).toDate(),
maxDate: moment().add( "months", 1 ).toDate(),
dateFormat: "d M, y",
constrainInput: true,
beforeShowDay: $.datepicker.noWeekends
});
});
當USer input時才載入.效能會比較好
$( document ).on( "focus", "input.date:not(.hasDatepicker)", function() {
toastr.info( "Initializing " + this.id );
$( this ).datepicker({
minDate: moment().subtract( "months", 1 ).toDate(),
maxDate: moment().add( "months", 1 ).toDate(),
dateFormat: "d M, y",
constrainInput: true,
beforeShowDay: $.datepicker.noWeekends
});
});
沒有留言:
張貼留言