bevacqua / rome

:calendar: Customizable date (and time) picker. Opt-in UI, no jQuery!
https://bevacqua.github.io/rome
MIT License
2.91k stars 223 forks source link

Keep date selection when switching month #138

Closed LostKobrakai closed 5 years ago

LostKobrakai commented 8 years ago

It would be nice if the selected date could only change with actually clicking a day and not automatically when switching the visible month.

arman-h commented 8 years ago

I'd like to see this option, as well.

TheKiesel commented 8 years ago

Yes, would be nice. Had the same problem. Found a solution though. In rome.standalone.js change the following:

  1. Change in the function changeMonth the update() call to update(true). It's a silent parameter and if set, switching of months don't automatically update the input field anymore.
  2. When you switch months and you close the calendar (eg. by clicking somewhere outside the calendar) but not by clicking any date, you probably don't want the last shown month and date fillded into the input field. To prevent it from doing so, remove or comment in the function invalidateInput the line with api.emitValues();

I did quite some other things as well and I cannot say if it has any unwanted side-effects, but so far everything works for me perfectly like that.