bootstrap3-datetimepicker-rails icon indicating copy to clipboard operation
bootstrap3-datetimepicker-rails copied to clipboard

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

Open andrewterra opened this issue 8 years ago • 6 comments

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 avatar Jun 03 '16 20:06 andrewterra

@TrevorS

andrewterra avatar Jun 03 '16 20:06 andrewterra

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

batmanbury avatar Jun 15 '16 17:06 batmanbury

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

TrevorS avatar Aug 27 '16 01:08 TrevorS

Similar error on the docs

andyklimczak avatar Dec 04 '16 01:12 andyklimczak

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

hibaAkroush avatar Mar 24 '18 17:03 hibaAkroush

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>

gnclmorais avatar Feb 11 '19 11:02 gnclmorais