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

Time select throws js error #6

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hey! I am getting a js error, when i click on the calender icon in order to select a time. CSS and JS is properly loaded. I am using Rails 4.1 and Ruby 2.1.1 and the latest JQuery.

This is what i have in my project:

Gemfile

gem 'momentjs-rails', '~> 2.5.0'
gem 'bootstrap3-datetimepicker-rails', '~> 3.0.0'

admin.css.sass

@import bootstrap
@import bootstrap-datetimepicker

admin.js.coffee

//= require jquery
//= require jquery_ujs
//= require select2
//= require moment
//= require bootstrap-datetimepicker
$ ->
  $('.js_datetimepicker').datetimepicker()

HTML(slim):

.form-group
    = f.label :start_date, class: "col-lg-3 control-label"
    .js_datetimepicker.input-group.date
      = f.datetime_field :start_date, class: 'form-control'
      span.input-group-addon
        span.glyphicon.glyphicon-calendar

The error which is accoring is the following:

Uncaught TypeError: undefined is not a function bootstrap-datetimepicker.js?body=1:752
(anonymous function) bootstrap-datetimepicker.js?body=1:752
jQuery.event.dispatch jquery.js?body=1:4625
elemData.handle

Any idea?

Thanks in advance.

erickva commented 10 years ago

I also have a JS error on the same line: 752 of bootstrap-datetimepicker.js It also happen when I click the Time button. Error is: TypeError: 'undefined' is not a function (evaluating 'expanded.collapse('hide')')

TrevorS commented 10 years ago

@MarkoHiel Hey you've got some funny indentation in your HTML snippet. I'm not very familiar with Slim, but maybe that has something to do with it? Check out this JSFiddle and see if you can recreate the issue.

TrevorS commented 10 years ago

@erickva Will you also try to recreate it with this JSFiddle?

ghost commented 10 years ago

Ah i see. But that's nothing to do with it. The JS Fiddle is working for me by the way.

mgechev commented 10 years ago

collapse is defined in bootstrap.js, so you need it in order to use the date time picker.

Add:

gem "therubyracer"
gem "twitter-bootstrap-rails"

in your Gemfile, run:

bundle install

And then add:

//= require twitter/bootstrap

in your application.js

I believe that this issue could be closed, bootstrap.js is an important dependency anyway.

erickva commented 10 years ago

Excellent! Thanks!

On 28 May 2014 19:23, Minko Gechev notifications@github.com wrote:

collapse is defined in bootstrap.js, so you need it in order to use the date time picker.

Add:

gem "therubyracer"gem "twitter-bootstrap-rails"

in your Gemfile, run:

bundle install

And add

//= require twitter/bootstrap

in your application.js

— Reply to this email directly or view it on GitHubhttps://github.com/TrevorS/bootstrap3-datetimepicker-rails/issues/6#issuecomment-44383031 .

ghost commented 10 years ago

Thanks! I missed that!

mgechev commented 10 years ago

You're welcome! I'm glad I helped.

TrevorS commented 10 years ago

Excellent work @mgechev, thanks!