Reputation: 1267
I am trying to implement datepicker in my simple_form much as has been covered here: How do i write a cleaner date picker input for SimpleForm
I create the custom class:
# app/inputs/date_picker_input.rb
class DatePickerInput < SimpleForm::Inputs::StringInput
....
end
I then add: `$("input.date_picker").datepicker();
at the bottom of application.js and use the code:
<%= f.input :deadline, :as => :date_picker %>
However, a datepicker is not activated, nor is an error thrown. Could this be an issue with me not understanding the asset pipeline correctly? My application.js also contains: //= require jquery.ui.datepicker.min
I also use the datepicker on a separate page in my application that does not use simple_form, so datepicker by itself is working.
Any suggestions would be appreciated.
Upvotes: 2
Views: 8442
Reputation: 8287
Make sure datepicker is called in your JavaScript (change datepicker class if it is different in your form):
$(function() {
$('input.datepicker').datepicker();
});
Also you can check How do i write a cleaner date picker input for SimpleForm or https://github.com/plataformatec/simple_form/issues/75#issuecomment-448362
Upvotes: 4