Project

flatpickr

0.04
Low commit activity in last 3 years
No release in over a year
Flatpickr packaged for use in Rails projects.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
~> 13.0
~> 3.0
 Project Readme

flatpickr

Gem Version

Flatpickr is a lightweight and powerful datetimepicker with no dependencies. This gem packages flatpickr's assets for drop-in use in Rails applications.

Installation

Add this line to your application's Gemfile:

gem 'flatpickr'

And then execute:

$ bundle

In your application.css, add the following:

*= require flatpickr

/* Optionally, you can include any of the flatpickr themes by adding in their styles, like so: */
*= require flatpickr/themes/dark

And in your application.js:

//= require flatpickr

document.addEventListener('DOMContentLoaded', function() {
  flatpickr('.your-selector');
})

Using Plugins

Flatpickr provides plugins which expand the library's functionality. To include the confirmDate plugin, for example, you must require the necessary assets and specify the plugin during initialization:

In your application.css:

*= require flatpickr
*= require flatpickr/plugins/confirmDate/confirmDate

In application.js:

//= require flatpickr
//= require flatpickr/plugins/confirmDate/confirmDate

document.addEventListener('DOMContentLoaded', function() {
  flatpickr('.your-selector', {
    enableTime: true,
    plugins: [
      new confirmDatePlugin({})
    ]
  })
})

See flatpickr's official docs for more configuration and usage details.

License

The gem is available as open source under the terms of the MIT License.