对于我尝试集成的任何时间选择器,javascript 控制台都会给我这个错误,尽管它确实适用于 datepicker。datetimepicker 也不起作用。
Uncaught TypeError: Object [object Object] has no method 'timePicker'
我尝试了许多不同的 timepicker 库,但它们都不起作用。
这是我的 application.js 文件:
//= require jquery
//= require jquery_ujs
//= require jquery.ui.all
//= require twitter/bootstrap
//= require bootstrap-datepicker
//= require bootstrap-timepicker
//= require jquery.timePicker
//= require jquery.timePicker.min
//= require schools
我的 application.css 文件:
*= require_self
*= require jquery.ui.all
*= require bootstrap_and_overrides
*= require formtastic-bootstrap
*= require formtastic_changes
*= require bootstrap-datepicker
*= require bootstrap-timepicker
*= require gmaps4rails
*= require schools
*= require timePicker
我的宝石文件:
gem 'rails', '3.2.8'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyracer', '~> 0.10.2'
gem 'uglifier', '>= 1.0.3'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem "twitter-bootstrap-rails"
end
gem 'sextant'
gem 'passenger'
gem 'formtastic', " ~> 2.1.1"
gem 'formtastic-bootstrap'
gem 'country_select'
gem 'slim'
gem 'redcarpet'
gem "auto_html"
gem 'gmaps4rails'
gem 'friendly_id'
gem 'devise'
gem 'capistrano'
gem 'unicorn'
gem 'bootstrap-datepicker-rails'
gem "bootstrap-timepicker-rails"
gem 'bcrypt-ruby', '~> 3.0.0'
group :development do
gem 'sqlite3'
end
group :production do
gem 'pg'
end
我的schools.js 文件('datepicker' 突出显示为粉红色,'timePicker' 突出显示为棕色。如果我将'timePicker' 更改为'datepicker' 以外的任何内容,它会保持棕色):
$(document).ready( function(){
$('#date_picker').datepicker();
$('.time_picker').timePicker();
});
我的观点:
<% if current_user %>
<h3>Create Reminder</h3>
<%= form_tag create_user_reminder_path, method: 'post' do %>
<%= select_datetime Time.now, :prompt => :date %>
<%= text_field_tag :date, nil, :id => "date_picker" %>
<div class="input-append bootstrap-timepicker-component">
<%= text_field_tag :time, nil, :class => "time_picker input-small" %>
<span class="add-on">
<i class="icon-time"></i>
</span>
</div>
<%= text_area_tag :message %>
<% if @school %>
<% unless @school.id == current_user.school_id %>
<%= hidden_field_tag :school_id, @school.id %>
<% end %>
<% end %>
<%= submit_tag 'Save Reminder' %>
<% end %>
<% end %>