formtastic_datepicker_inputs
formtastic_datepicker_inputs copied to clipboard
Use different class names for datetime fields and date fields
It's a problem that you'd have to use custom class names in order to have both a date field and a datetime field on the same page. Am I missing something here or should the two fields have different class-names in order for the jQuery to work?
= f.input :started_at, as: :datetime_picker,
input_html: { class: 'datetime-field' }
= f.input :ends_at, as: :datetime_picker,
input_html: { class: 'datetime-field' }
= f.input :expires_on, as: :date_picker,
input_html: { class: 'date-field' }
(function($){
$(document).ready(function(){
$('input.date-field').datepicker({
firstDay: 1,
dateFormat: 'yy-mm-dd'
});
$('input.datetime-field').datetimepicker({
firstDay: 1,
dateFormat: 'yy-mm-dd',
timeFormat: 'hh:mm:ss'
});
});