views:

29

answers:

2

Hi i'm sure there must be an easy way to do this but can't find the option to set it anywhere.

I am trying disable the left/right buttons that allow the user to change months. I've removed the drop down list of months but can't get rid of the buttons.

    $("#date").datepicker({
    changeMonth: false,
    changeYear: false,
    dateFormat: 'dd/mm/yy',
    duration: 'fast'
});
+1  A: 

You can effectively disable them using stepMonths by making them go nowhere when clicked, like this:

$("#date").datepicker({
  changeMonth: false,
  changeYear: false,
  dateFormat: 'dd/mm/yy',
  duration: 'fast',
  stepMonths: 0
});

You can give it a try here

Or, you could remove the buttons like this:

$("#date").datepicker({
  changeMonth: false,
  changeYear: false,
  dateFormat: 'dd/mm/yy',
  duration: 'fast'
}).focus(function() {
  $(".ui-datepicker-prev, .ui-datepicker-next").remove();
});​

You can give that a try here, this works because the default showOn option is focus, if you're using a different event, just bind to that after the .datepicker() call (so its event runs first, you can't hide what isn't created yet).

Nick Craver
Thanks Nick, they both did the trick but have gone with removing the buttons alltogether.
JBoom
A: 

I don't know how to do it directly in jQuery (or if it's possible).

But if you can't find a way to do it in there, you could always just hide the buttons in css.

The css selectors you want are (from memory so you might need to check)

.ui-datepicker .ui-datepicker-prev, 
.ui-datepicker .ui-datepicker-next
{
    display:none;
}
fearofawhackplanet