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

Uncaught TypeError: undefined is not a function #25

Closed rnjailamba closed 9 years ago

rnjailamba commented 9 years ago

I was using :

$(function () {

                    $('#datetimepicker1').datetimepicker();

});

and was getting the error

The error was solved by using:

var j = jQuery.noConflict();

j(document).ready(function(){

                   j('#datetimepicker1').datetimepicker();

})

Is there any reason for this?

TrevorS commented 9 years ago

Are you using any other Javascript libraries? Can you reproduce it in a JSFiddle?

rnjailamba commented 9 years ago

 Havent been able to reproduce the issue,the other libraries are the following:

My application.js file includes the following:

//= require jquery

//= require jquery-ui

//= require jquery_ujs

//= require bootstrap

//= require jquery.turbolinks

//= require turbolinks

//= require moment

//= require bootstrap-datetimepicker

//= require masonry/jquery.masonry

//= require_tree .

 

And below are all my script tags:

<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html5.min.js">

 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"&gt;&lt;/script&gt;

  <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false&libraries=places&language=en-US"&gt;&lt;/script&gt;

rnjailamba commented 9 years ago

Using (document).on('ready page:load', function () { $('#datetimepicker1').datetimepicker(); });

rather than

$(function () { $('#datetimepicker1').datetimepicker(); });

fixes the issue.You can close this now.Thanks

TrevorS commented 9 years ago

Ok great, glad you were able to figure it out. :)