zpaulovics / datetimepicker-rails

A date and time picker for Twitter Bootstrap in Rails using Simple Form
MIT License
174 stars 80 forks source link

PickTime option not working #53

Closed complitech closed 9 years ago

complitech commented 9 years ago

Uncaught TypeError: option pickTime is not recognized!

$('.datepicker').datetimepicker(
  {
    pickTime: false
  });
zpaulovics commented 9 years ago

You are right. The option you have used was valid with Version v1.0.0. The current call is:

$(document).on('ready page:change', function() {
  $('.datetimepicker').datetimepicker({
    // put here your custom picker options, that should be applied for all pickers

  });
});

The valid options are (with their default values):

        format: false,
        dayViewHeaderFormat: 'MMMM YYYY',
        extraFormats: false,
        stepping: 1,
        minDate: false,
        maxDate: false,
        useCurrent: true,
        collapse: true,
        locale: moment.locale(),
        defaultDate: false,
        disabledDates: false,
        enabledDates: false,
        icons: {
            time: 'glyphicon glyphicon-time',
            date: 'glyphicon glyphicon-calendar',
            up: 'glyphicon glyphicon-chevron-up',
            down: 'glyphicon glyphicon-chevron-down',
            previous: 'glyphicon glyphicon-chevron-left',
            next: 'glyphicon glyphicon-chevron-right',
            today: 'glyphicon glyphicon-screenshot',
            clear: 'glyphicon glyphicon-trash',
            close: 'glyphicon glyphicon-remove'
        },
        useStrict: false,
        sideBySide: false,
        daysOfWeekDisabled: [],
        calendarWeeks: false,
        viewMode: 'days',
        toolbarPlacement: 'default',
        showTodayButton: false,
        showClear: false,
        showClose: false,
        widgetPositioning: {
            horizontal: 'auto',
            vertical: 'auto'
        },
        widgetParent: null,
        ignoreReadonly: false,
        keepOpen: false,
        focusOnShow: true,
        inline: false,
        keepInvalid: false,
        datepickerInput: '.datepickerinput'

Zoltan

jpmermoz commented 9 years ago

So, how can we pick just the date part and not time? Thanks!

zpaulovics commented 9 years ago

Hi,

It is very simple. Just use the following SimpleForm example:

<%= simple_form_for @course, wrapper: :horizontal_form, 
    :html => { :class => 'form-horizontal' } do |f| %>
    <%= f.error_notification %>

    ...

    <%= f.input :start_date, as: :date_picker, :label => 'Start date' %>
    <%= f.input :end_date, as: :date_picker, :label => 'End date' %>
<% end %>

Zoltan

roadev commented 9 years ago

It's working for me with the SimpleForm example :D