JQuery UI Datepicker, reverse the order of the year in the dropdowns

后端 未结 6 538
梦毁少年i
梦毁少年i 2020-12-01 16:58

I have a datepicker with changeyear: true. The \'year\' drop down displays the title as 2009, then instead of the next year below the title being 2008, 2007, 2006 and so on

6条回答
  •  我在风中等你
    2020-12-01 17:04

    • Open the file ui.datepicker.js
    • Find the method _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate, selectedDate, secondary, monthNames, monthNamesShort)
    • Find the following loop in the method

      for (; year <= endYear; year++) {
          html += '';
      }
      
      html += '';
      
    • Insert the following code before that loop:

      if (year-100 < 1900) // Check year is lower then 1900
          year = 1950;     // change start point of above loop, it helps you having the 
                           // year's dropdownlist starting at 1950, and ending of current year plus 10.
      

提交回复
热议问题