bootstrap日期选择器轨道无法通过带有bootstrap模式的simple_form工作
bootstrap-datepicker-rails not working via simple_form with bootstrap modal
我正试图让一个日期选择器(使用bootstrap日期选择器rails gem)通过具有bootstrap模式的simple_form进行显示,但没有成功。
我读过很多东西,比如:
https://github.com/Nerian/bootstrap-datepicker-rails/issues/51如何设置引导程序日期选择器轨道?http://learningnewtricks.wordpress.com/2013/07/03/bootstrap-date-picker-on-rails-so-simple/http://www.chadcf.com/blog/jqueryui-datepicker-rails-and-simpleform-easy-way
我得到的只是一个文本字段,但当我点击它时,没有日期选择器。可能是日期选择器在模式后面吗?如果是,如何解决?
我的设置如下:
fyousuf$ rails -v
Rails 3.2.12
fyousuf$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.3.0]
app/assets/stylesheets/application.css
*= require_self
*= require fullcalendar
*= require bootstrap-datepicker
*= require_tree .
app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require twitter/bootstrap
//= require bootstrap
//= require fullcalendar
//= require bootstrap-datepicker
//= require_tree .
app/assets/javascript/s/events.js
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
$('[data-behaviour~=datepicker]').datepicker({"format": "yyyy-mm-dd", "weekStart": 1, "autoclose": true});
app/views/events/_form.html.erb
<%= simple_form_for(@event) do |f| %>
...
<%= f.input :starts_at, :as => :string, :input_html => { data: {behaviour: "datepicker"}} %>
...
<% end %>
在我的视图中
= f.input :first_name
= f.input :last_name
= f.input :date_of_birth, as: :string, input_html: { class: "datepicker" }
在我的应用程序.js上
$(function() {
$('input.datepicker').data({behaviour: "datepicker"}).datepicker();
});
我正在使用的版本
> bundle | grep bootstrap
Using bootstrap-datepicker-rails 1.3.0.2
Using twitter-bootstrap-rails 2.2.8
这对我来说非常有效。加载表单后,如果我点击输入"date_of_firth",就会出现日期选择器。
相关文章:
- 如何动态更改React Bootstrap模式的内容
- 在Bootstrap模式窗口中打开远程内容
- bootstrap模式在windowsvista上的IE8上运行极其缓慢
- Jquery UI don'使用bootstrap 3模式时效果不佳
- 在ajax回调(safari)中调用bootstrap模式显示
- 一旦Bootstrap模式选项已经存在,请更改该选项
- 当内部的任何模式关闭时,Bootstrap模式关闭
- bootstrap日期选择器轨道无法通过带有bootstrap模式的simple_form工作
- Bootstrap 3模式从水平到内联的变化-调整大小很尴尬
- Twtitter Bootstrap模式显示事件多次触发
- 确定哪个按钮打开了Bootstrap 3模式
- 如何使用 javascript 隐藏 Bootstrap 模式
- Bootstrap模式加载远程内容,生成2个请求
- c#asp.net如何使用bootstrap模式将视频源文件名添加到不同的媒体类型中
- bootstrap模式中的Twitter共享按钮在firefox上不起作用
- Bootstrap 3模式并不总是激活ajax代码
- PHP和Bootstrap模式变量
- Bootstrap 3模式-从底部滑入并粘牢
- 如何清理(销毁)Twitter Bootstrap 3.2模式表单内容
- 如何在AngularJS Bootstrap模式中从AJAX调用加载JSON数据