Rails 3 Asset Pipeline:JQuery Datepicker正在运行,但Timepicker根本不起作用

时间:2012-12-04 16:53:01

标签: jquery ruby-on-rails-3 jquery-ui twitter-bootstrap timepicker

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

我的Gemfile:

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'突出显示为棕色。如果我将&timeCicker'更改为&#39以外的任何内容39; 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 %>

1 个答案:

答案 0 :(得分:0)

不是$('.time_picker').timepicker();而不是$('.time_picker').timePicker();吗?

(注意时间戳中的小'p')