Home Rails 4 - Bootstrap-datepicker - Uncaught TypeError: $(...).datepicker is not a function
Reply: 0

Rails 4 - Bootstrap-datepicker - Uncaught TypeError: $(...).datepicker is not a function

user1034
1#
user1034 Published in May 22, 2018, 11:45 am

I installed the gem.

gem 'bootstrap-datepicker-rails'

Added this line to application.css

*= require bootstrap-datepicker3

Added this line to application.js

//= require bootstrap-datepicker

And put this into my form:

<div class="form-group">
    <%= f.label :start_date %><br>
    <%= f.text_field :start_date, data:{ provide:'datepicker' } %>
</div>

It works fine, however I would like to customize the date format, so I changed it to this:

<%= f.text_field(:start_date, {:class => 'datepicker' }) %>

<script type="text/javascript">
  $(document).ready(function(){
    $('.datepicker').datepicker({
      format: 'yyyy-mm-dd'
    });
  });
</script>

This doesn't work and gives me the following error:

Uncaught TypeError: $(...).datepicker is not a function

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.300534 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO