datepicker (drop down calendar) - YaleSTC/reservations GitHub Wiki
Project and implementation info
https://github.com/albertopq/jquery_datepicker
Added to Reservations/rails3_upgrade branch on 2012.06.12 by @dgoerger in order to give a popup calendar for selection of start_date and due_date.
Where / How we use it
<%= datepicker_input "[model_name, e.g. user]", "[name of datafield, e.g. birthday]" :value => cart.start_date.strftime('%m/%d/%Y') %>
Files edited
- Gemfile => gem 'jquery_datepicker'
- application.js => require jquery, jquery-ujs, jquery-ui (on separate lines, in that order)
- views/reservations/_cart_sidebar.html.erb, in the above syntax
- views/catalog/_quicksearch.html.erb, in the above syntax
- controllers/application_controller.rb, the update_cart function
- controllers/catalog_controller.rb, the update_cart* function
Things to watch out for
- If dataTables is broken, datepicker might be, also. Fixing dataTables seems to resolve the issue.
- We need to make sure in the controller to indicate that the datepicker input is in the format '%m/%d/%Y' format. If not, rails will assume it's in '%d/%m/%Y' format and give errors for any inputted day past twelve (since there are not thirteen months).
- If you modify Datepicker formatting (e.g. we disable selection of dates-past), set the defaults in application.js like this: $.datepicker.setDefaults({ minDate: new Date(), prevText: '' });