bootstrap3-datetimepicker-rails
bootstrap3-datetimepicker-rails copied to clipboard
Getting a $(...).datetimepicker is not a function error
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 .
@TrevorS
@TrevorS I have virtually the same situation and haven't found a solution other than including files manually.
I will look into this. Sorry for the super late response.
Similar error on the docs
make startDateTime is put on the input not somewhere else like a div
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>