How can I set a different class to past dates on the jQuery UI Datepicker? -


is there way set previous selected dates of jquery ui datepicker different class?

the scenario dealing there calendar upcoming events , previous events. upcoming events right class applied them , styled accordingly. need same previous dates had event.

so instance:

may 10th colored gold (highlight class) because it's upcoming event.

may 8th colored light gray (passed-event class) because it's previous event.

here have far (working beforeshowday):

beforeshowday: function(date) {                     var result = [true, '', null],                         afterortoday = $.grep(events, function(event) {                              var eventdate = new date(event.date),                                 todaysdate = new date();                              return date.valueof() === eventdate.valueof();                         }),                         beforetoday = $.grep(events, function(event) {                              var eventdate = new date(event.date),                                 todaysdate = new date();                              return date.valueof() < eventdate.valueof();                         });                      if (afterortoday.length)                         result = [true, 'highlight', null];                     else if (beforetoday.length)                         result = [true, 'passed-event', null];                      return result;                 } 

not sure if efficient method, , love recommendations on changes improve quality, here solution came with.

beforeshowday: function(date) {     var result = [true, '', null],         today = $.grep(events, function(event) {              var eventdate = new date(event.date);              return date.valueof() === eventdate.valueof();         }),         beforetoday = $.grep(events, function(event, i) {              var eventdate = new date(event.date),                 ispast = false;              if (date.valueof() === eventdate.valueof())                 if (date.valueof() < new date().valueof())                     ispast = true;              return ispast;         });      if (today.length)         result = [true, 'highlight', null];      if (beforetoday.length)         result = [true, 'past-event', null];      return result; } 

this add class past dates had events future dates in 2 separate classes. everyone!


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -