EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: lusabo on March 13, 2012, 07:14:13 AM



Title: Datebox + Calendar
Post by: lusabo on March 13, 2012, 07:14:13 AM
Hi All,

I have a datebox field and I'd like to change the months name on calendar that appears with datebox. How to do it?

$(".campoData").datebox({
  currentText: "Hoje",
  closeText: "Fechar",
  formatter: function(date){
      var y = date.getFullYear();
      var m = date.getMonth() + 1;
      var d = date.getDate();
      return (d<10?('0'+d):d)+'/'+(m<10?('0'+m):m)+'/'+y;
  },
  parser: function(s){
      if (!s) return new Date();
      var ss = s.split('/');
      var d = parseInt(ss[0],10);
      var m = parseInt(ss[1],10);
      var y = parseInt(ss[2],10);
      if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
         return new Date(y,m-1,d);
            } else {
         return new Date();
      }
           }
   });


Title: Re: Datebox + Calendar
Post by: stworthy on March 13, 2012, 06:51:02 PM
The datebox is created based on calendar and the month names is defined in calendar.
The easiest way to change the month names is to override the calendar default property:

$.fn.calendar.defaults.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];