title: Jquery UI datepicker setDate not working on dynamic change of formatDate
body: <p>I'm trying to add a button in the control pane of my datepicker. It should allow to show the name of the whole month, instead of a specific date.</p>
  
  <p>I need both behaviors (date picker and month picker) but it seems that the dynamic change of date format crashes the widget. Commented code has the same problem.</p>
  
  <pre><code>var dateToday = new Date();
  var maxDate = "+365";
  $('.datepicker').datepicker({
    minDate: dateToday,
    maxDate: maxDate,
    dateFormat: "dd-mm-yy",
    changeMonth: true,
    changeYear: true,
    showButtonPanel: true,
    onChangeMonthYear: function(year, month, instance) {
        var thisCalendar = $(this);
        setTimeout(function() {
            var buttonPane = $(instance)
                .datepicker("widget")
                .find(".ui-datepicker-buttonpane");
  
            $("&lt;button&gt;", {
                text: "Whole month",
                click: function() {
                    var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
                    var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
                    thisCalendar.datepicker("option", "dateFormat", "MM yy");
                    thisCalendar.datepicker('setDate', month + "/01/" + year);
                    //thisCalendar.datepicker('setDate', new Date(year, month, 1));
                    //thisCalendar.datepicker("refresh");
  
                }
            }).appendTo(buttonPane).addClass("ui-datepicker-clear ui-state-default ui-priority-primary ui-corner-all");
        }, 1);
    }
  
  })
  </code></pre>
  
  <p>This fiddle shows my issue: <a href="https://jsfiddle.net/mLewc6ep/3/" rel="nofollow">https://jsfiddle.net/mLewc6ep/3/</a>. The button appears only on next months, not the current one. If you click on it, it always shows the same month (e.g. August 2021, as of today).</p>