zpaulovics / datetimepicker-rails

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

Uncaught TypeError: option pickTime is not recognized! #71

Open jfly opened 8 years ago

jfly commented 8 years ago

The README suggests that we add the following javascript to our project:

    $(document).on('ready page:change', function() {
        $('.datepicker').datetimepicker({
            pickTime: false
        });
    });

    $(document).on('ready page:change', function() {
        $('.datetimepicker').datetimepicker({
            pickSeconds: false
        });
    });

    $(document).on('ready page:change', function() {
        $('.timepicker').datetimepicker({
            pickDate: false,
            pickSeconds: false
        });
    });

However, bootstrap-datepicker no longer has these pick* options. I get the following error when trying to use them:

Uncaught TypeError: option pickTime is not recognized!

Instead, the hasTime and hasDate methods look at actualFormat to determine if time or date pickers are needed. To get things working for my datepicker, I found that specifying a format works to get hasTime to return false:

  $('input.date_picker').datetimepicker({
    format: "yyyy-mm-dd",
  });