bootstrap 日期选择器日历未出现 Rails 3
bootstrap datepicker calendar is not coming in Rails 3
我在我的 Rails app.But 中包含了 bootstrap 日期选择器 app.But 它没有显示 anything.Please 检查我的以下代码。
Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.19'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
gem "bcrypt-ruby", :require => "bcrypt"
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
gem 'bootstrap-datepicker-rails', '>= 0.6.21'
#gem 'bootstrap-datepicker-rails'
gem 'will_paginate', '~> 3.0'
view_report.html.erb:
<div class="input-group bmargindiv1 date" id='datepicker' data-date-format="yyyy-mm-dd" data-date="2015-05-01" data-behaviour='datepicker' >
<%= form_tag reports_view_report_path, :method => 'get' do %>
<%= text_field_tag :search, params[:search], :class => "form-control", :onchange => 'this.form.submit();'%>
<% end %>
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
</span>
<script type="text/javascript">
$(function() {
$('#datepicker').datepicker()
});
</script>
</div>
application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>SwargadwaraPuri</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<link rel="stylesheet" href="/assets/bootstrap-2.0.css">
<link rel="stylesheet" href="/assets/plugins-2.0.css">
<link rel="stylesheet" href="/assets/main-2.0.css">
<link rel="stylesheet" href="/assets/themes-2.0.css">
</head>
<body class="login no-animation" >
<%= yield %>
<script src="/assets/bootstrap.min-2.0.js"></script>
<script type="text/javascript" src="/assets/bootstrap-filestyle.min.js"></script>
<script src="/assets/plugins-2.0.js"></script>
<script src="/assets/main-2.0.js"></script>
</body>
</html>
application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap-datepicker
//= require_tree .
//= require_self
application.css:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*=bootstrap-datepicker
*/
我需要像 yyyy-mm-dd
这样的日期格式。请帮我解决这个问题 issue.I 我正在使用 Rails 版本 3.2.9。
将以下文件添加到 application-default.js
文件中,
//= require bootstrap-datepicker
//= require bootstrap-datepicker/core
//= require bootstrap-datepicker/locales/bootstrap-datepicker.es.js
//= require bootstrap-datepicker/locales/bootstrap-datepicker.fr.js
将以下文件添加到 application-default.css.scss
*= require bootstrap-datepicker
改变你的javascript喜欢,
$('#datepicker').datepicker({
format: "yyyy-mm-dd"
});
要查看如何更改日期格式,请查看这些 bootstrap datepicker 并单击该页面上的在线演示 link。
我在我的 Rails app.But 中包含了 bootstrap 日期选择器 app.But 它没有显示 anything.Please 检查我的以下代码。
Gemfile:
source 'https://rubygems.org'
gem 'rails', '3.2.19'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
gem "bcrypt-ruby", :require => "bcrypt"
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
gem 'bootstrap-datepicker-rails', '>= 0.6.21'
#gem 'bootstrap-datepicker-rails'
gem 'will_paginate', '~> 3.0'
view_report.html.erb:
<div class="input-group bmargindiv1 date" id='datepicker' data-date-format="yyyy-mm-dd" data-date="2015-05-01" data-behaviour='datepicker' >
<%= form_tag reports_view_report_path, :method => 'get' do %>
<%= text_field_tag :search, params[:search], :class => "form-control", :onchange => 'this.form.submit();'%>
<% end %>
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
</span>
<script type="text/javascript">
$(function() {
$('#datepicker').datepicker()
});
</script>
</div>
application.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>SwargadwaraPuri</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<link rel="stylesheet" href="/assets/bootstrap-2.0.css">
<link rel="stylesheet" href="/assets/plugins-2.0.css">
<link rel="stylesheet" href="/assets/main-2.0.css">
<link rel="stylesheet" href="/assets/themes-2.0.css">
</head>
<body class="login no-animation" >
<%= yield %>
<script src="/assets/bootstrap.min-2.0.js"></script>
<script type="text/javascript" src="/assets/bootstrap-filestyle.min.js"></script>
<script src="/assets/plugins-2.0.js"></script>
<script src="/assets/main-2.0.js"></script>
</body>
</html>
application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap-datepicker
//= require_tree .
//= require_self
application.css:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*=bootstrap-datepicker
*/
我需要像 yyyy-mm-dd
这样的日期格式。请帮我解决这个问题 issue.I 我正在使用 Rails 版本 3.2.9。
将以下文件添加到 application-default.js
文件中,
//= require bootstrap-datepicker
//= require bootstrap-datepicker/core
//= require bootstrap-datepicker/locales/bootstrap-datepicker.es.js
//= require bootstrap-datepicker/locales/bootstrap-datepicker.fr.js
将以下文件添加到 application-default.css.scss
*= require bootstrap-datepicker
改变你的javascript喜欢,
$('#datepicker').datepicker({
format: "yyyy-mm-dd"
});
要查看如何更改日期格式,请查看这些 bootstrap datepicker 并单击该页面上的在线演示 link。