zpaulovics / datetimepicker-rails Goto Github PK
View Code? Open in Web Editor NEWA date and time picker for Twitter Bootstrap in Rails using Simple Form
License: MIT License
A date and time picker for Twitter Bootstrap in Rails using Simple Form
License: MIT License
The dropdown works fine. However, the up and down arrow to increment/decrement minute and hour does not appear. This is because the color is matching with the background. When I hover over it, the area around it turns grey so the arrow remains white but becomes visible. Same icon in the link (https://eonasdan.github.io/bootstrap-datetimepicker/#linked-pickers) appears fine. How do I fix this?
I can't hover and then take a screenshot as the dropdown goes away. I cannot even inspect the element as clicking on it hides the widget. Any suggestions to inspect the element would be welcome too.
I can't seem to view the 'changeDate' event being called. Does this gem alter the event binding? I'm trying to get the date via Javascript to update other attributes on the page.
$('.datetimepicker').datetimepicker().on('changeDate', function(ev){ console.log(' date changed '+ ev.date); });
I want to disable the previous dates to select. How can I achieve that.
I am trying various combinations of dformat and pformat, but doesn't seem to be working. Can you provide a bit of explanation on what dformat and pformat are for exactly?
Hi!
I'm new to Rails, and I'm trying to set up a simple Rails site, to a understanding for how it works.
I'd like to use your gem, but I cannot make it work, as I get the error:
wrong number of arguments (0 for 1)
Do you have any idea, why that might be?
I've followed your instructions, and created a page with nothing but a date input field.
If I remove the Ruby code, and just use the HTML and Javascript exampla it works fine.
Is there, or can anyone provide a
Good working example for datepicker-rails and bootstrap 3 + simple_form?
All the examples here and on stackoverflow + the example app all fail.
Followed all instructions, only moved the assets from vendor in my regular asset pipeline ( since i need some custom paths )
Using this:
= f.input :expire_at, as: :date_picker,
:label => false,
input_html: {data: {date_options: { defaultDate: '12-01-2015', showClose: true }}}
There are 2 problems
Any thought on resolving above? lots of people have issue with getting this to work with rails perhasp a single writeup with the steps needed would help alot.
Latest version of datetimepicker-rails now causes an error in browser console related to not being able to find moment.js? Is this now a requirement?
Hey there,
just ran the installer, but i'm getting this error
Sprockets::FileNotFound - couldn't find file 'moment' with type 'application/javascript':
When I save moment.js to the folder it runs normally
Well I used to use:
<gem 'datetimepicker-rails', :require => 'datetimepicker-rails', :git => 'git://github.com/zpaulovics/datetimepicker-rails.git'>
However this no longer works so I switched to using:
<gem 'datetimepicker-rails', '>= 3.0.0', :git => 'git://github.com/zpaulovics/datetimepicker-rails.git', \ :branch => 'master', :submodules => true>
I added the css/js dependancies to my assets. I get no errors but the datepicker is not showing.
I am using bootstrap 2.3.2. Is it still supported?
I tried: <gem 'datetimepicker-rails', github: 'git://github.com/zpaulovics/datetimepicker-rails.git', tag: '1.0.0'>
but I get a git clone error when trying to bundle install.
What can I try? How come I cant use: <gem 'datetimepicker-rails', :require => 'datetimepicker-rails', :git => 'git://github.com/zpaulovics/datetimepicker-rails.git'>
anymore?
I am using Simple Form and cannot figure out how to set the time_picker to use 12 hour format rather than 24 hour format.
I have tried
$('.time_picker').datetimepicker({
pick12HourFormat: true
})
and
$('.time_picker').datetimepicker({
use24hours:false
})
The error I am receiving is 'option pick12HourFormat is not recognized!'
I additionally have tried to pass it as a data attribute with no luck.
Hi there,
I have the installed according to the docs, and everything works great except the datetime field "Calendar" doesn't pop up by hovering or clicking on the field.
Will you please help me out here, I really need some help.
Thank you
Attempting to get a date field working with the following line:
<%= f.input :golive_date, :as => :date_picker %>
But it gives me the following error:
Showing /home/leigh/Projects/dev01/app/views/customers/_form.html.erb where line #9 raised: wrong number of arguments (0 for 1)
app/inputs/date_picker_input.rb:2:in``input'
app/views/customers/_form.html.erb:9:in``block in _app_views_customers__form_html_erb__1186218440755357997_69863682644920'
app/views/customers/_form.html.erb:1:in``_app_views_customers__form_html_erb__1186218440755357997_69863682644920'
app/views/customers/new.html.erb:4:in``_app_views_customers_new_html_erb___3618363883504976842_69863682680540'
My application and version details are:
Rails version is: Rails 4.1.4
OS version is: Ubuntu 14.04 LTS
Ruby version is: ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
Gem details are:
leigh@leigh-VirtualBox:/Projects/dev01$ bundle install/Projects/dev01$
Using rake 10.3.2
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.0
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.4
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.4
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.4
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.4
Using activemodel 4.1.4
Using arel 5.0.1.20140414130214
Using activerecord 4.1.4
Using execjs 2.2.1
Using autoprefixer-rails 2.2.0.20140804
Using bcrypt 3.1.7
Using sass 3.2.19
Using bootstrap-sass 3.2.0.1
Using thor 0.19.1
Using railties 4.1.4
Using bootswatch-rails 3.2.0
Using cancan 1.6.10
Using coffee-script-source 1.7.1
Using coffee-script 2.3.0
Using coffee-rails 4.0.1
Using data-confirm-modal 1.0.1 from git://github.com/ifad/data-confirm-modal.git (at master)
Using datetimepicker-rails 3.0.3 from git://github.com/zpaulovics/datetimepicker-rails.git (at master)
Using orm_adapter 0.5.0
Using warden 1.2.3
Using devise 3.2.4
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.1.3
Using jquery-rails 3.1.1
Using momentjs-rails 2.8.1
Using pg 0.17.1
Using bundler 1.6.4
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.4
Using rdoc 4.1.1
Using sass-rails 4.0.3
Using sdoc 0.4.1
Using simple_form 3.0.2
Using spring 1.1.3
Using sqlite3 1.3.9
Using turbolinks 2.2.2
Using uglifier 2.5.3
Your bundle is complete!
Use bundle show [gemname]
to see where a bundled gem is installed.
leigh@leigh-VirtualBox:
I have tried all 3 gem file options for datetimepicker-rails and all fail in the same way.
Any ideas on what might be causing this issue?
Is it possible to use this widget on a select_date ?
I am using Rails4, Ruby2, and Bootstrap 2.3.2.
I have installed everything according to the instructions and restarted my server.
Using this line in a simple_form:
<%= f.input :delivery_date, :as => :date_picker %>
I receive the following error: wrong number of arguments (0 for 1)
The following function is defined in /app/inputs/date_picker_input.rb:
class DatePickerInput < SimpleForm::Inputs::StringInput
def input(wrapper_options)
value = object.send(attribute_name) if object.respond_to? attribute_name
display_pattern = I18n.t('datepicker.dformat', :default => '%d/%m/%Y')
input_html_options[:value] ||= I18n.localize(value, :format => display_pattern) if value.present?
input_html_options[:type] = 'text'
picker_pettern = I18n.t('datepicker.pformat', :default => 'DD/MM/YYYY')
input_html_options[:data] ||= {}
input_html_options[:data].merge!({ date_format: picker_pettern, date_language: I18n.locale.to_s,
date_weekstart: I18n.t('datepicker.weekstart', :default => 0) })
template.content_tag :div, class: 'input-group date datepicker' do
input = super(wrapper_options) # leave StringInput do the real rendering
input += template.content_tag :span, class: 'input-group-btn' do
template.content_tag :button, class: 'btn btn-default', type: 'button' do
template.content_tag :span, '', class: 'fa fa-calendar'
end
end
input
end
end
def input_html_classes
super.push '' # 'form-control'
end
end
Clearly, the function is expecting an input (wrapper_options), but in the github instructions, the use for simple_form specifies:
<%= f.input :closing_date, :as => :date_picker %>
Any ideas on how to solve this issue?
I don't think the new version is respecting the pformat properly.
In my config/locales/en.yml file I have tried:
pformat: 'YYYY-MM-DD'
and..
pformat: 'yyyy-MM-dd'
Neither of these change the format when picking the date. Are you able to reproduce this?
Hello,
just wanted to let you know we've released v4 to the master branch.
If you want to be informed about major publishing ahead of time, please drop me a line at myusername @ outlook.com
Hi,
Thanks for all your great work on this gem.
I have tried to use the readme instructions for including the gem, but for some reason seem to keep picking up an outdated version of the Eonasdan bootstrap3-datetimepicker-rails submodule. I have the following line in my Gemfile:
gem 'datetimepicker-rails', '~> 3.0.3', :git => 'git://github.com/zpaulovics/datetimepicker-rails.git', \ :branch => 'master', :submodules => true, tag: '3.0.3'
I then run:
$ bundle install $ rails generate datetimepicker_rails:install
However, when I check the file vendor/assets/javascripts/bootstrap-datetimepicker.js, it has the header:
Version 3.0.0 bootstrap-datetimepicker.js https://github.com/Eonasdan/bootstrap-datetimepicker
And the code doesn't work because it is not compatible with the latest momentjs. (see TrevorS/bootstrap3-datetimepicker-rails#17)
Is there something wrong about the way I am trying to load your gem in my Gemfile? Is there some additional flags I could add to the Gemfile entry so that I can specify which Eonasdan module to load with datetimepicker-rails?
Thank You!
Hi all,
I would like to translate datetimepicker-rails I follow the readme but the locales aren't included. I've tried with the originals from plugin but doesn't work. Does anyone know how to make it work?
I can change few parameters on the YML file but I want to translate the ui of the plugin.
Thanks!
If I use the following entry in my gem file, the fetch doesn't work:
gem 'datetimepicker-rails', github: 'zpaulovics/datetimepicker-rails', branch: 'master', submodules: true
The error is the following:
Fetching git://github.com/zpaulovics/datetimepicker-rails.git
fatal: Could not parse object 'e41ba7f805d1eca19153ff91b27423a4aff5e4b6'.
The install script is not installing bootstrap-datetimepicker.js
. My guess is that this is because it just globs the js folder, and since there's nothing there it fails silently. I manually cloned the repo and copied over the js file and everything works fine now.
# Gemfile
...
gem 'datetimepicker-rails', github: 'zpaulovics/datetimepicker-rails', branch: 'master', submodules: true
gem 'momentjs-rails', '~> 2.9', github: 'derekprior/momentjs-rails'
...
# Shell
$ bundle exec rails generate datetimepicker_rails:install Font-Awesome
gsub app/inputs/datetime_picker_input.rb
gsub app/inputs/date_picker_input.rb
gsub app/inputs/time_picker_input.rb
icon_family: Font-Awesome
vendor assets/javascripts/pickers.js
identical vendor/assets/stylesheets/bootstrap-datetimepicker.min.css
identical vendor/assets/stylesheets/bootstrap-datetimepicker.css
gem 'datetimepicker-rails', github: 'zpaulovics/datetimepicker-rails', branch: 'master', submodules: true
gem 'momentjs-rails', '~> 2.9', :github => 'derekprior/momentjs-rails'
gem 'rails', '4.2.3'
chuck@chuck-MacBook-Pro:~/seaify/project(master↑1|✔) % ruby -v (master10)
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
//= require moment
//= require bootstrap-datetimepicker
//= require pickers
Any options for rendering the calendar inline, instead of a popup?
In development enviroment i dont need simple_form gem, but when i change to production mode i have unitializing constant SimpleFor (My app dont use this Gem). For now, i include this dependency in my Gemfile and works, but i think its wrong...
There is the option to auto-close when select the date?
Any plans on updating to the latest version of bootstrap-datetimepicker in the 4.x.x series? Its now on v4.15.35.
There is no weekStart option.
in your configuration , you it's stated 👍
//= require moment
//= require bootstrap-datetimepicker
//= require pickers
but I get an error
ActionView::Template::Error (couldn't find file 'moment'
from where this file should be coming from ?
I added the javascripts/locales/bootstrap-datetimepicker.js
and required it in my application.js : //= require locales/bootstrap-datetimepicker.fr
in my application layout , I added also 👍
= javascript_tag "window.locale = #{I18n.locale.to_s.inspect};"
but I don't get the datetimepicker using the :fr locale ... did I missed anything else ?
Is there any documentation of how to handle timezones? I’m currently stuck on the 1.0.0 branch and I’m not seeing any options for handling datetime. If you could point me to some examples that would be much appreciated.
Also, if I wanted to just hide the text field and automatically show the calendar, is that supported? I also didn’t see any examples of that in the documentation so I’m just wondering.
Thanks for your work! This is pretty much the only datetimepicker for Rails that is actively maintained.
In my Gemfile
:
gem 'datetimepicker-rails', :git => 'git://github.com/zpaulovics/datetimepicker-rails.git', :branch => 'master', :submodules => true
In my application.js
...
//= require bootstrap-datetimepicker
...
In my application.css
...
*= require bootstrap-datetimepicker
...
But when I load the page I have an error:
couldn't find file 'bootstrap-datetimepicker' (in .../app/assets/javascripts/application.js:16)
Could you help me, please? What can be a problem?
I'm getting the following error in app/inputs/datetime_picker_input.rb
= f.input :expires, as: :datetime_picker
wrong number of arguments (0 for 1)
Any ideas how to fix?
I apologize for asking a similar question to a previous closed item, but I did all of the js includes:
// = require moment
// = require bootstrap-datetimepicker
// = require pickers
And after doing bundle install and restarting server, I'm still getting:
couldn't find file 'pickers'
.... I went to rubygems.org and can't find any gem associated with 'pickers', and I'm not sure which dependency this points to... can you help me out?
How to pass options to datepicker ?
I tried my own datetime_picker.js
$('.datepicker').datetimepicker({
pickTime: false,
startView: 2
});
I tried data attributes
=f.input :my_date, as: :date_picker, input_html: {data: { date_start_view: 2 } }
I tried modify the input
input_html_options[:data].merge!({ format: picker_pettern, language: I18n.locale.to_s, start_view: 2})
none of them worked ><
I am customizing the time format in en.yml file. I have:
timepicker:
dformat: '%l:%M %p'
pformat: 'HH:mm'
dformat makes sense to me because it uses the standard ruby format directives.
pformat however is not so clear. What type of directive is this using? I am trying to print AM/PM after HH:mm but I am unsure of the syntax.
I get this error after following the example:
"Could not find method for :datetime_picker"
Any help is appreciated..
Hi,
I'm hoping for some help. Since moving our form into a modal the datetimepicker is no longer working as expected.
We are using the version tagged with v1.0.0
for bootstrap 2.3 compatibility, simple_form (3.0.2), ruby (2.1.2) on rails (4.1.6).
# _form.html.haml
= simple_form_for employee, remote: modal, html: {class: 'form-horizontal' } do |f|
.modal-header
- if modal
%button.close{"aria-hidden" => "true", data: {dismiss: "modal"}, type: "button"} x
%h3= header_text
.modal-body
= f.input :first_name
= f.input :last_name
= f.input :birth_date, :as => :date_picker
= f.input :gender, collection: [:male, :female]
= f.input :personnel_number
#modal-footer.modal-footer
.pull-right
- if modal
%button.btn.btn-link{type: "button", "data-dismiss" => "modal"}
= t('employee.actions.cancel')
- else
= link_to t('employee.actions.cancel'), cancel_path, class: 'button btn btn-link'
= f.button :submit, submit_text, id: 'submit', class: 'btn btn-primary'
Clicking on the date picker for the birth_date field resulted in nothing happening. At first we thought it may of been a z-index issue but this doesn't seem to be the case. Going from #1 it seems the picker needs initialised when used within a modal. Some javascript was added to the form with limited success...
:javascript
$(function() {
$('#employee_birth_date').datetimepicker({
pickTime: false,
});
});
Screenshot
Thanks for any help in advance
Hi there,
sadly the Gem does not work for me. I can not update simple_form to the rc Version, because forem depends on the current version.
Any help appreciated!
Cheers,
Kaikas
Error: wrong number of arguments (0 for 1)
View _form.html.erb:
<%= f.input :datetime, :as => :datetime_picker %>
Gemfile:
gem 'momentjs-rails', '2.7.0'
gem 'datetimepicker-rails', :git => 'git://github.com/zpaulovics/datetimepicker-rails.git',
:branch => 'master', :submodules => true
rails 4.1.4
ruby 2.1.0p0
Using bootstrap-sass (3.2.0.1)
Using forem-bootstrap (0.0.1) from git://github.com/radar/forem-bootstrap.git (at master)
I'm new to Rails. Where should the following code be placed?
<script type="text/javascript"> $('.datetimepicker').datetimepicker(); </script>I believe this may be the issue but here's the erro that I'm receiving.
NoMethodError in Appts#new
Showing /vagrant/projects/PremierDerm/app/views/appts/_form.html.erb where line #26 raised:
undefined method `input' for #ActionView::Helpers::FormBuilder:0x228427c8
Extracted source (around line #26):
</div>
<div class="field">
<%= f.input :start_date_time, :as => :datetime_picker %>
</div>
<div class="actions">
<%= f.submit %>
Trace of template inclusion: app/views/appts/new.html.erb
I am experiencing a problem where when a date on the calendar is clicked, instead of filling the value and hiding the calendar like it supposed to, a second calendar shows directly below the first calendar and then it becomes unusable. Any idea of what might be causing this?
^
I have followed the installation instructions carefully, and the date picker is working fine, but the icons are not appearing in the popup and the button to popup the calendar is sitting well to the right of the form.
This is Bootstrap 3 and Rails 4.2.1
TIA, Dave
The datepicker does not pop up on load, but it will show if the page is refreshed manually.
Uncaught TypeError: option pickTime is not recognized!
$('.datepicker').datetimepicker(
{
pickTime: false
});
I was wondering if there is a way to pass options from SimpleForm?
I see that I can add default options in pickers.js (var default_picker_options=) but I think this will apply the same options every time I use :as => :date_picker
It would be handy if different options could be passed from SimpleForm depending on the field. For example "defaultDate" can be useful for "published_on" field but not for a "birthdate" field...
Hello, i'm using your gem but i can't find a way to close the date window after select a date, can you lead me how to do that?
Thank you in advance :D
Hi,
I have this issue while using the gem where say one of the validation fails and the page is re rendered. Before the create actionit looked like 12/02/2015 04:13 PM, create action fails due to validation and now the DateTime field has value 12/02/2015 hh:mm
Hello,
I get the locales/en.yml to work. What I can't do is to override the options. For instance:
timepicker:
dformat: '%l:%M %
pformat: 'HH:mm A'
With this the time picker works ok ( 11:28 PM)
But when I try to customize it in a certain page
//= require moment
//= require bootstrap-datetimepicker
//= require pickers
$(document).on('ready page:change', function() {
$('datetimepicker').datetimepicker({
format: 'HH:mm'
});
});
The format won't be overridden.
With the options directly on simple form it also won't change the locales format.
= f.input :trip_duration, as: :time_picker, as: :time_picker, input_html: { data: { date_options: { format: 'HH:mm'} } }
Is that overriding possible?
Hi,
how i can hook DateChange event?? I tried:
$('.date').datetimepicker({
locale: 'pt-BR',
format: 'DD/MM/YYYY HH:mm:ss A',
onChange = function(e){
console.log("Fire");
}
});
$('.date').datetimepicker({
locale: 'pt-BR',
format: 'DD/MM/YYYY HH:mm:ss A',
}).on("change", function(e){
console.log("Fire again");
});
but not working...
When doing
<%= f.input :start_date_time, :as => :datetime_picker %>
it throws this error. Not sure why. Any thoughts?
Using the latest of everything... 3.0.2+ and latest moment.js.
How can I add a custom locale to datetimepicker (such as a Korean language or Hercsex language locale?) ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.