我正在尝试使用http://trentrichardson.com/examples/timepicker/时间选择器。我有ruby 1.9.3p484和rails 4.1.0版本。我已经将来自上述网站的jquery-ui-timepicker addon.css包含在我的app/assets/stylesheets/application.css.scss中。我还将jquery-ui-timepicker addon.js复制到app/assets/javascripts中。
在我的Gem文件中,我添加了
gem 'jquery-rails'
gem 'jquery-ui-rails'在我添加的app/assets/javascripts/application.js文件中
//= require jquery-ui
//= require jquery-ui-timepicker-addon
$( function(){
$("#tpicker").timepicker();
});在我的app/assets/stylesheets/application.css.scss中,我添加了
*= require jquery-ui还有底部的jquery-ui-timepicker addon.css(位于http://trentrichardson.com/examples/timepicker/)中的CSS。
问题是这样的。在我的html.erb中,我有以下内容
<%= f.text_field :time, id: "tpicker" %>但是,当单击或键入给定的text_field时,时间选择器不会显示。请帮帮我!
发布于 2015-07-03 17:36:20
在我看来,应该是这样的:
$( function(){
$('#tpicker').timepicker();
$('#tpicker').on('click', function (){
$('#tpicker').timepicker('setTime', new Date());
});
});有关其他示例,请阅读此jquery.timepicker demos and documentations
发布于 2015-07-03 19:37:31
这就是它的工作原理。我将所有的javascript都包含在我的页面文件的标签中。它现在工作了,除了我必须刷新页面才能工作的事实。它不能在第一次工作。
https://stackoverflow.com/questions/31202720
复制相似问题