TrevorS / bootstrap3-datetimepicker-rails

This gem packages the bootstrap-datetimepicker for the Rails 3.1+ asset pipeline.
MIT License
292 stars 123 forks source link

Getting a $(...).datetimepicker is not a function error #39

Open andrewterra opened 8 years ago

andrewterra commented 8 years ago

I am getting this error when attempting to load my page. I followed the directions in how to install and looked around at other issues that had this problem but their solutions did not fix mine.

This is my application.html.erb file includes

<head>
  <title>Loadtest</title>
  <%= stylesheet_link_tag    'application.css', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application.js', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>

  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width = device-width, initial-scale = 1">
  <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
  <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Ubuntu">

</head>

This is how I call the datetimepickers

                 $('.startDateTime').datetimepicker({
                     defaultDate: new Date(startDate),
                     useUtc:true,
                     sideBySide:true
                 });
                 $('.endDateTime').datetimepicker({
                     defaultDate: new Date(endDate),
                     useUtc:true,
                     sideBySide:true
                 });

This is my application.css I know that require bootstrap isnt here but I link it in the application.html.erb file

 *= require_self
 *= require bootstrap-datetimepicker
 *= require template
 * require_tree .

Finally this is my application.js file

require turbolinks
//= require jquery
//= require jquery_ujs
//= require moment
//= require bootstrap-datetimepicker
//= require template
//= require tree .
andrewterra commented 8 years ago

@TrevorS

batmanbury commented 8 years ago

@TrevorS I have virtually the same situation and haven't found a solution other than including files manually.

TrevorS commented 8 years ago

I will look into this. Sorry for the super late response.

andyklimczak commented 7 years ago

Similar error on the docs

hibaAkroush commented 6 years ago

make startDateTime is put on the input not somewhere else like a div

gnclmorais commented 5 years ago

If you have require jquery and require bootstrap-datetimepicker on your application.js (and assuming you have the right gems installed), you shouldn’t need these:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>