Jibroottan Jibroottan - 4 months ago 30
PHP Question

Show next/prev month name instead of next/prev icon button in jQueryUI Datepicker

I want a datepicker like this

screenshot

But now the problem is it shows the previous month but not next month.

screenshot

My jQuery code :

<script type="text/javascript">
var jqueryarray = <?php echo json_encode($dates1); ?>
function available(date) {
dmy = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear();
if (jQuery.inArray(dmy, jqueryarray) != -1) {
return [true, "",""];
} else {
return [false,"",""];
}
}
jQuery('#datespicker').datepicker({
beforeShowDay: available,
numberOfMonths: [1, 2],
//stepMonths: 2,
navigationAsDateFormat: true,
nextText: 'M',
prevText: 'M'
});
</script>

Answer Source

I get your problem, you can do one thing to solve this.

Open your jquery-ui.js file and find this line

nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText, this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ), this._getFormatConfig( inst ) ) );

and replace with this

nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText, this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths+1, 1 ) ), this._getFormatConfig( inst ) ) );

I hope you understand. :) Enjoy :)