Reputation: 1
I need a date and time calender in form. I found the gem datetimepicker-rails , Now i am trying to implement that like the below way, but it is not showing any error and also not working.
Step 1: i added the gem in Gemfile, step 2: bundled install, step 3: added the below line in application.css file like below,
*= require_self
*= require jquery.ui.all
*= require bootstrap-datetimepicker
*= require_tree ./vendor/
step 4: added the line in application.js file like below ,
//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require bootstrap-datetimepicker
//= require_tree ./vendor/
//= require_tree ./launchpad/
//= require_tree .
step 5: i generated a input files using following command: $ rails generate datetimepicker_rails:install step 6: I changed the form like below:
<%= simple_form_for [current_user, @task], html: {class: 'form-vertical', role: "form"} do |f| %>
<%= f.error_notification %>
<%= f.input :requested_pickup_dt, as: :datetime_picker %>
<%= f.button :submit %>
<%end%>
But it is not showing any error also not working. please someone help me to resolve this issue.
Upvotes: 0
Views: 4153
Reputation: 8574
After your inputs are on the page you may need to actually call the datetimepicker
function.
You could put this at the very bottom of your page :
<script type="text/javascript">
$('.datetimepicker').datetimepicker({});
</script>
Or you could use the jQuery ready function to delay the init until the document is ready:
$(function() {
$('.datetimepicker').datetimepicker({});
});
You'll want to double check the generated source and make sure that your input has datetimepicker
in the class attribute.
Upvotes: 1